[fpc-pascal] Problem with string manager

Joao Morais jcmoraisjr at gmail.com
Thu Sep 10 15:23:54 CEST 2009

On Wed, Sep 9, 2009 at 5:08 PM, Jonas Maebe <jonas.maebe at elis.ugent.be> wrote:
> On 09 Sep 2009, at 21:10, Joao Morais wrote:
>> The following cgi script shows "??" in the browser if cwstring is
>> declared, and works as expected if the declaration is removed. Is
>> there something I can change in order to work with widestrings,
>> cwstring and special chars? fixes_2_4 with linux.
> a) bug: you are not specifying to the compiler in what code page the strings
> in your source code are encoded. As a result, the compiler will assume it's
> the default (8859-1), unless their is an UTF-8 BOM (in which case the
> compiler parses it as UTF-8)
> b) when you use cwstring, the RTL will convert any widestring you write to
> the current locale. Under *nix this is defined by the "LANG" environment
> variable (which in turn controls the various LC_* environment variables). If
> the current locale does not support the character you try to write, you will
> get question marks.
> I guess what's happening if you don't use cwstring and don't specify a code
> page, that the compiler dumps the character as it appears in the source code
> straight into the widestring without any conversion, and that the rtl later
> on extracts it (when "converting" from widestring to ansistring) also
> without any conversion. So it only happens to work because the code page in
> which you wrote the source code happens to be the same as the code page that
> the browser at the other side uses as default.

Thanks Jonas for your valuable comments.

Please, have a look at http://lpweb.com.br/dl/enc.html

I prepared this table in order to choose which configuration I should
use. The best option is UTF-8 source without cwstring, but sometimes I
need to link with libraries that uses this unit. What I am missing or
which configuration I can change?

Joao Morais

More information about the fpc-pascal mailing list