[fpc-pascal] TStringHelper and Utf8String

Marco van de Voort fpc at pascalprogramming.org
Mon Aug 31 13:38:31 CEST 2026


Op 31-8-2026 om 11:47 schreef Juha Manninen via fpc-pascal:
>>
>> Set these 3 CodePages to CP_UTF8:
>>   SetMultiByteConversionCodePage(CP_UTF8);
>>   SetMultiByteRTLFileSystemCodePage(CP_UTF8);
>>   SetMultiByteFileSystemCodePage(CP_UTF8);
>>
>> and you are good to go.
>>
> LazUTF8 also sets callbacks on Windows for AnsiCompareStr(), 
> AnsiCompareText() and similar functions.
>
> I didn't know about the "winmanutf8lfn", I guess it does the same thing.

No, it does the same as the manifest options, which works at the windows 
level, not at the RTL level. So at startup of the exe the system 
encoding is directly utf8, for everything, so also the windows api.

The only downside is that it requires windows 10 (actually a 201903 
version of windows 10, but older versions than that are long unsupported).

This means for supported windows versions, anything "ansi", no manual 
conversions are needed any more, and you can pass a ansistring 
containing utf8 directly to the windows API with pchar(thestring).

The only place where manual conversions are needed are for file and wire 
formats with specific encoding requirements, and maybe some special api 
(console/OEM ?)




More information about the fpc-pascal mailing list