[fpc-pascal] FPC 3.x for Windows and code page conversion

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Nov 23 17:29:36 CET 2015


Lubos Pintes wrote on Mon, 23 Nov 2015:

> I am developing a console application which receives an UTF-8  
> encoded text through stdin.
> The text is, after possible modification, sent to SAPI5. The SAPI5  
> generated interface wrappers have parameters of type string.
> In FPC 2.6.4, I used UTF8toANSI on various places and that worked  
> well. Now after reading about FPC 3.x's unicode support, I thought  
> that adding this line say after begin in the main program could be  
> enough:
> SetMultiByteConversionCodePage(CP_UTF8);
> It however doesn't work.

That routine sets the default code page for ansistrings. It does not  
change I/O.

> How can I solve this without conversion to ANSI?

The code page can be set per I/O channel:  
http://www.freepascal.org/docs-html/3.0.0/rtl/system/settextcodepage.html (and  
Michael: I just noticed a typo on that page, under "Description" it  
says GetTextCodePage instead of SetTextCodePage)


Jonas



More information about the fpc-pascal mailing list