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

Daniël Mantione daniel.mantione at freepascal.org
Wed May 9 10:24:22 CEST 2007



Op Wed, 9 May 2007, schreef Christos Chryssochoidis:

> OK, I figured out what happened. The source file was saved in UTF-8 encod=
ing,
> but I hadn't put in my source file the compiler directive {$CODEPAGE UTF8=
}.
> After including this directive in my code almost everything worked fine:
> length() was returning the right number of unicode characters, and
> subscripting the widestring returned the right character. But as the wide=
char
> and widestring encoding is, as you said, UTF-16, while my Mac OS X console
> uses UTF-8 encoding, for the output results to be displayed correctly I h=
ad to
> wrap the individual widechars or the whole widestring with the function
> utf8encode(), prior to output them with write()...

This means no widestring manager was used; the default dumb widestring =

manager converts to iso-8859-1. Use the "cwstring" unit will use the =

system encoding when reading/writing widestrings.

Dani=EBl


More information about the fpc-pascal mailing list