[Lazarus] Set UTF-8 in RTL has create error in const definitaion

Mattias Gaertner nc-gaertnma at netcologne.de
Sun Feb 15 16:52:26 CET 2015


On Sun, 15 Feb 2015 17:10:06 +0200
FreeMan <freeman35 at delphiturkiye.com> wrote:

> -dUseCThreads
> -FcUTF8
> -dEnableUTF8RTL
> 
> thats in my project options, compiler Options -> other
> I get same error. I can not compile.
> 
> this from my test, I remove Turkish chars from variable definition, 
> compiled project, and ShowMessage result is normal view. I mean chars 
> painting normal
> 
> var TBS_Captions2: array[0..2, 0..1] of string[15] = ( 
> ('Anamnez','ANAMNEZ'),('Bal Dosyalar','BALI DOSYALAR'),('Notlar','NOTLAR'));
> begin
> TBS_Captions2[1,0]:= 'Bağlı Dosyalar';
> TBS_Captions2[1,1]:= 'BAĞLI DOSYALAR';
> ShowMessage(TBS_Captions2[1,0] + LineEnding + TBS_Captions2[1,1]);

The string[15] is a shortstring.
You can assign only systemcodepage literals to Shortstring.

Solutions:
a) change the constant to String.
b) Put the constant into a unit with system codepage. For example:

unit unit2;

{$mode objfpc}{$H+}
{$ModeSwitch systemcodepage} // disabling -FcUTF8

interface

const
  s: string[15] = 'äöü';

end.


Mattias




More information about the Lazarus mailing list