Page 1 of 1

TXT file create

Posted: Tue Jan 11, 2022 9:10 pm
by serge_girard
Hello,

I need to create a TXT file as UTF-8.
Now I create standard ANSI, Edit the file in my editor and SAVE it as UTF-8.

Can I do this from within my PRG?

Thanks, Serge

Re: TXT file create

Posted: Tue Jan 11, 2022 10:16 pm
by edk
Hallo, probeer het eens op deze manier.

Code: Select all

set( _SET_CODEPAGE, "PLWIN" )
cANSI := "Zażółć gęślą jaźń"		/* <- String Windows-1250 Encoded */

HB_MemoWrit( "Text file UTF-8 Encoded.txt", UTF8_BOM + hb_StrToUTF8( cANSI, "PLWIN") )  /* file UTF-8 Encoded with Byte Order Mark */
HB_MemoWrit( "Another Text file UTF-8 Encoded.txt",  hb_StrToUTF8( cANSI, "PLWIN") )  /* file UTF-8 Encoded without Byte Order Mark */

Re: TXT file create

Posted: Wed Jan 12, 2022 2:09 pm
by serge_girard
Thanks Edward,

I will take a look at it shortly !
My data comes from SQL database and contains French, Spanish and German languages (for the time being) and is put into a TXT file by my program.
The file with the UTF8_BOM is indeed saved as UTF8 but content is messed up: Fran�ois instead of François.
I need to same this was hardcoded in my program and the PRG is save as ANSI.
I will try with real data this week.

Thanks again!


Serge