[fpc-pascal] How to find the byte offset of the n-th character in an UTF-8 string?

Roland Schaefer roland.schaefer at fu-berlin.de
Tue Sep 8 11:36:18 CEST 2009


Hi all,
I have a situation where I internally work with AnsiStrings but need to
convert them to UTF-8 before passing them to libpango, which I do with
AnsiToUtf8(). I then need the byte offset of one specific (varying)
character in the UTF-8 string, which is not trivially available since
some characters are encoded in 2 bytes. Before I start my own hacks: Is
there a nice way of finding the byte offset of the n-th character in an
UTF-8 string?

Thanks a lot.
Regards
Roland



More information about the fpc-pascal mailing list