[fpc-devel] FPC 2.3.1 seems a mixed mess with Unicode support

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Sep 15 14:20:53 CEST 2009


On 15 Sep 2009, at 14:15, Florian Klaempfl wrote:

> Jonas Maebe schrieb:
>>
>>> ä  is not 世 as the website described the result to be.
>>
>> That's because you did not specify the code page of the source  
>> code, in
>> which case it's parsed as CP 8859-1. Add {$codepage utf-8} or save  
>> the
>> file with an UTF-8 BOM and it will work fine.
>
> Graeme said he did tell the compiler that he uses utf-8.


Then he probably made a mistake, because it works for me:

$ cat tt.pp
{$codepage utf-8}

program test3;

{$mode objfpc}{$H+}
uses
  cwstring, Classes, SysUtils;

var
  MyChar: UnicodeChar;
  MyString: UnicodeString;
begin
  MyString := '世界您好';
  MyChar := MyString[1];
  writeln(MyChar);
end.
$ ppn34 tt
Target OS: Linux for i386
Compiling tt.pp
Linking tt
16 lines compiled, 2.4 sec
$ ./tt
世
$ echo $LANG
en_US.UTF-8
$ uname -a
Linux traxx 2.6.18-92.1.22.el5PAE #1 SMP Tue Dec 16 07:10:07 EST 2008  
i686 i686 i386 GNU/Linux

If I remove the "{$codepage utf-8}", then I also get ä as output.


Jonas


More information about the fpc-devel mailing list