I have found that national characters like ÄÖüß and so on do not show correctly in a UTF-8 coded managed application when read from an ASCII file created by a native app. Based on an answer I read here on encoding I came up with this code: method-id UTF_conversion. procedure division. * Specify the code page to correctly interpret byte values set wsEncoding to type Encoding::GetEncoding(1252) * Windows set codePageValues to Auftragrec * sequential file to be displayed set n3 to codePageValues::Length * set Original length of ASCII set tAUFTRAGrec to Auftragrec * save record to temporary record * Same content is now encoded as UTF-8 set unicodeValues to wsencoding::GetString(codePageValues) set cAUFTRAGrec to unicodevalues * for Display * Same content "äöüß" is stored as UTF-8 initialize Auftragrec set A-Empfaenger to cA-Empfaenger * set item containing national characters displayed in list box as only data set Auftragpath to Auftrags-datei * save path for temporary usage set Auftrags-datei to Tempdatei invoke type System.IO.File::WriteAllText(Auftrags-datei, unicodeValues) set compareValues to type System.IO.File::ReadAllBytes(Auftrags-datei) set n4 to compareValues::Length * new unicode length subtract n3 from n4 giving n2 * add n2 to length of display item in Listbox call "CBL_DELETE_FILE" using Auftrags-datei returning return-code * reset values set Auftragrec to tAuftragrec set Auftrags-datei to AuftragPath goback end method. it is quite awkward and my question is: Can I get the new length without saving and re-reading the file? It is necessary because the national characters don't seem to be recognized as such in a list box and without setting the field length to - length + No. of national chars - the displayed fields vary in size. I cannot just convert and save the file because when printing, the result of CHAR to OEM conversion doesn't work. But maybe I'm just using the wrong code?
↧