Convert codepages back to UTF8

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Convert codepages back to UTF8

AlexeyT
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?

--
Regards,
Alexey

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Convert codepages back to UTF8

Free Pascal - General mailing list
Alexey Tor. <[hidden email]> 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. 

Regards, 
Sven 

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal