[Lazarus] API-Import of "PUTF8Char"
Martok
listbox at martoks-place.de
Sat Sep 3 23:55:44 CEST 2016
Hi List,
I'm writing an API interface that passes #0-terminated cstrings with encoding
UTF8. What data type should be used to declare these parameters so that I may be
able to use as much of 3.0+'s automatic encoding conversion as possible?
Some example declarations would look like:
procedure SetUserID(const NewValue: PUTF8Char);
function GetUserID(const Buf: PUTF8Char; const BufLength: UInt32): UInt32;
If I read the wiki correctly, PAnsiChar would not be clear as it is always
assumed to be CP_ACP, causing the compiler to generate conversions to
DefaultSystemCodePage. I'm posting this to the Lazarus list instead of
fpc-pascal because I already use LazUTF8 so CP_ACP really is CP_UTF8, but I want
to be sure that the header always works whether LazUTF8 is used or not.
Is there a good way to do what I want, or would it be easier to use PUnicodeChar
and pass the strings as UTF-16? How well would other languages work with that?
Thank you for any hints,
Martok
More information about the Lazarus
mailing list