[fpc-pascal] How to find the byte offset of the n-th character in an UTF-8 string?
Martin
lazarus at mfriebe.de
Tue Sep 8 12:18:57 CEST 2009
Have a look at LCLProc in lazarus.
function UTF8CharToByteIndex(UTF8Str: PChar; Len, CharIndex: PtrInt):
PtrInt;
Roland Schaefer wrote:
> 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
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list