[fpc-pascal] Parse unicode scalar
genericptr at gmail.com
Tue Jul 4 03:03:07 CEST 2023
> On Jul 4, 2023, at 1:15 AM, Mattias Gaertner via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> function ReadUTF8(p: PChar; ByteCount: PtrInt): PtrInt;
> // returns the number of codepoints
> CodePointLen: longint;
> CodePoint: longword;
> while (ByteCount>0) do begin
> ...do something with the CodePoint...
Thanks, this looks right. I guess this is how we need to iterate over unicode now.
Btw, why isn't there a for-loop we can use over unicode strings? seems like that should be supported out of the box. I had this same problem in Swift also where it's extremely confusing to merely iterate over a string and look at each character. Replacing characters will be tricky also so we need some good library functions.
Swift is especially terrible because there's NO ANSII string so even a 1 byte sequence needs all these confusing as hell functions to do any work with strings at all. Terrible experience and slooooow.
More information about the fpc-pascal