BaBernd
11th November 2015, 09:40
Hello to All,

I create a text file (csv/txt) out of a multibyte field during executing a report. The correct umlaute (ü,ä,ö) will be transformed into (›¼ü, ›¼ä, ›¼ö). Where does these additional signs (›¼) come from?

for text file creation I use the following code:

declaration:
string buf(1,1) based |dynamic Array
string filename(512) |file name
string textbuffer(4096) | buffer for item text
long xml.text
long xml.fp |XML-Filepointer
long xml.root |root-Node
long xml.item |article-Node
long xml.ret |return value


Detail.1:
before.layout:
textbuffer = ""
free.mem(buf) |reinit from array buffer
select tttxt002.nlin
from tttxt002
where tttxt002._index1 = {:tcibd001.txta, :lattr.textlang$}
selectdo
endselect

alloc.mem(buf,132,tttxt002.nlin)
xml.ret = text.to.buf("tcibd001.txta",lattr.textlang$,tttxt002.nlin,buf)
for xml.i = 1 to tttxt002.nlin
textbuffer = textbuffer & trim$(buf(1,xml.i)) & " "
endfor

xml.text = xmlnewdataelement("ARTIKELBEZ",trim$(textbuffer), xml.item)

| creating the file
after.program:
if xml.root then
filename = "ITEMS-" & trim$(sprintf$("%u(%04Y-%02m-%02d-)%U(%02h-%02m-%02s)",utc.num(),utc.num())) & "-" & logname$ & ".xml"
xml.fp = seq.open(filename, "wt+")
xml.ret = xmlwritepretty(xml.fp, xml.root, 0)
xml.fp = seq.close(xml.fp)
xml.ret = server2client(filename, "c:\temp\" & filename, true)
xml.ret = start.application.local("excel.exe c:\temp\" & filename, false, xml.ret)
endif


It's not the full code but the important parts (I think so):
- text.to.buf()
- xmlwritepretty()

From which one of These functions I will get These additional signs "›¼"?

Best Regards
Bernd

bhushanchanda
11th November 2015, 11:10
Hi,

Try adding BOM sequence to the file i.e. 3 special characters as the start of the file data. Also, you might need to convert the data using utf8.export()

Excel doesn't handle the data without adding the sequence.

Refer this thread - Similar Thread (http://www.baanboard.com/baanboard/showthread.php?t=62724)

BaBernd
11th November 2015, 15:02
Hello Bhushan,

again you have the solution for me :-).

Only inserting BOM => also some strange signs for the umlaute
Only using utf8.export() => also some other strange signs for the umlaute

But using both: BOM and utf8.export() was successful as you predicted.

Thanks a lot!

Best Regards
Bernd