PDA

View Full Version : direct_output encoding change



colw
26-Oct-2021, 10:43 PM
Hi there, wondering if anyone can point me in the best direction rather than re invent a wheel somewhere.

I am just looking at converting df19 to df20 and the first thing was a simple utility that writes a text file using 'direct_output'. I quickly discovered that not all things can now read that file as it is utf8 encoded.

Question is.. what is a simple way to still write the old OEM text format (including chars from 127 to 255) ?. I can see in this forum that it may be possible to use Uchar data type to build the data to output but that seems a bit clumsy and I am hoping there is a simple way (as always) such as 'direct_output channel 1 filemode:OEM' or something similar.

Thanks,
Col.

Vincent Oorsprong
27-Oct-2021, 02:58 AM
Col,

AFAIK the only option is the use of the UTF8ToOem function (https://docs.dataaccess.com/dataflexhelp/#t=mergedProjects%2FLanguageReference%2FUtf8ToOem. htm).

colw
27-Oct-2021, 05:11 PM
Col,

AFAIK the only option is the use of the UTF8ToOem function (https://docs.dataaccess.com/dataflexhelp/#t=mergedProjects%2FLanguageReference%2FUtf8ToOem. htm).

Vincent,

Thanks for the prompt response. I thought I did try that and when I opened it with notepad++ it still said it was utf8 encoded, although I have tried lots of things so I might give it another go.

I did though discover (read the documentation - who would have thought) that the other product I was using to open the text file was defaulting to OEM but had an option to specify utf8 in the file open statement so it is in fact now working using utf8.

Thanks again,
Col.

Harm Wibier
29-Oct-2021, 03:54 AM
Just to add to that: Notepad++ in a lot of cases can only guess the encoding of a file. UTF-8, OEM and ANSI are all the same as long as you only use ASCII characters. Even when using extended characters it still can't always recognize it (definetely not the difference between OEM and ANSI), but then you can check if the characters are displayed correctly to see if Notepad++ assumed the right format.