[fpc-devel] assign constant text to widestring

Daniël Mantione daniel.mantione at freepascal.org
Thu Oct 23 09:59:44 CEST 2008



Op Thu, 23 Oct 2008, schreef Michael Schnell:

> I suppose this might solve the constant assignment on the fly, but in fact I 
> feel that the compiler should generate a WideString constant at compile time 
> instead of calling a conversion function at run time.

Then you don't understand it yet, I think. If the compiler knows your 
source file is UTF-8 (by BOM or directive), the compiler generates a 
widestring constant and no conversion function is called when assigning to 
a widestring.

However, if you assing this constant to an utf8string, the compiler does a 
wide->ansi conversion, which is done according to the system code page, as 
the compiler does not know the difference between an ansistring and an 
utf8string. In this case you would need to utf8decode your 
widestring constant to get in in your ansistring in UTF-8 encoding.

Daniël


More information about the fpc-devel mailing list