[fpc-pascal] Convert codepages back to UTF8

Sven Barth pascaldragon at googlemail.com
Tue May 28 17:09:04 CEST 2019

Alexey Tor. <aaa5500 at ya.ru> schrieb am Di., 28. Mai 2019, 14:44:

> Ok, I got it. But I wonder: if my code changes codepage of a "string" to
> e.g. 1250, will all Lazarus string functions work ok with such changed
> string? For ex, will Pos('Петя', s) work?

Depends on what you do with the returned value. Lazarus uses UTF-8 by
default, thus the constant would be in UTF-8 as well and Pos() takes two
AnsiString parameters, thus CP_ACP. So the constant is passed along as is
and s is converted to UTF-8. Depending on the encoding of the characters
you might get a different position, thus you should ensure that both of
your strings have the same type (not tested) or you should work simply in
UTF-8 and only convert for input/output purposes.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20190528/1e6b7b6c/attachment.html>

More information about the fpc-pascal mailing list