[fpc-pascal] FPC Unicode / CodePage aware strings

Jonas Maebe jonas.maebe at elis.ugent.be
Thu Dec 10 12:16:48 CET 2015

Graeme Geldenhuys wrote on Thu, 10 Dec 2015:

> On 2015-12-10 10:29, Jonas Maebe wrote:
>> The language feature is implemented in a Delphi 2009-compatible way
>> (although some Delphi-specific behaviour is only activated in {$mode
>> delphiunicode}).
> Okay, so forget Delphi 2009 compatibility for the moment (I don't use
> Delphi). So does this mean to use "official" FPC Unicode, I can't use
> {$mode objfpc} any more?

There is no such thing as "official FPC Unicode". We added support for  
codepage-aware ansistrings. We added unicodestring overloads for a  
number of RTL routines, and made sure that those same routines also  
correctly handle the ansistring codepage information. This  
functionality is always available everywhere, and behaves the same  

We also added the {$mode delphiunicode} syntax mode, which changes  
some type definitions ((p)char = (p)widechar, string in {$h+} =  
unicodestring), and the default source file code page in a Delphi 2009  
and later compatible way. It does not modify the above functionlaty,  
nor is it required.

> No problem, I changed the example to a console program and used
> WriteLn() instead.

The test program you posted later does not work completely because it  
uses routines that have not yet been adapted (UpCase and ToUpper are  
not mentioned in  
http://wiki.freepascal.org/FPC_Unicode_support#RTL_changes ).

> Does WriteLn() work correctly with Unicode text?


> Will it detect my
> console encoding used in mate-terminal or xterm under FreeBSD?

It will use whatever code page has been (correctly) configured for  
your terminal, yes.

> As past experience has shown me, the wiki is a very unreliable source -

Wiki articles that are linked from official release notes are by  
definition supported and guaranteed to be reliable by us.

> But I'll spend my lunch time reading the wiki page in question and see
> if anything helps. But like I said, the experience thus far is anything
> but ideal or straight forward.

You seem to be looking for a tutorial. We have written no such  
document. There is only a technical description of what has been added  
and how it behaves.


More information about the fpc-pascal mailing list