[fpc-pascal] Re: Widestrings length and character iteration

Christos Chryssochoidis c.chryssochoidis at gmail.com
Mon May 7 17:27:37 CEST 2007




Daniël Mantione wrote:
 >
 > Op Mon, 7 May 2007, schreef Christos Chryssochoidis:
 >
 >> Hi,
 >>
 >> Are there any rtl functions to compute the length (in characters) of a
 >> widestring and to iterate over its characters?
 >
 > If you treat it as UCS-2: length(widestring_variable)
 >
 >>  In my system (Mac OS X/fpc 2.1.3), a widestring is implemented as a 
UTF-8
 >> encoded string, as I found out.
 >
 > Not possible, a widestring is UCS-2/UTF-16.

  I defined a widestring with 7 characters (code points), and the 
length() function returned the value 15. Of the 7 code points of that 
widestring only one of them was greater than $07FF (the maximum code 
point which can be encoded in 2 bytes under UTF-8). When I changed that 
character with another one with code not greater than $07FF, length() 
returned value 14... I also printed the byte values of one of the 
widestring's widechars, and the values printed indicated UTF-8 encoding.

Thanks,
Christos


 >
 > Daniël
 >
 >
 > ------------------------------------------------------------------------
 >
 > _______________________________________________
 > fpc-pascal maillist  - 
fpc-pascal-PD4FTy7X32k2wBtHl531yWD2FQJk+8+b at public.gmane.org
 > http://lists.freepascal.org/mailman/listinfo/fpc-pascal






More information about the fpc-pascal mailing list