Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-02

Set UTF-8 in RTL has create error in const definitaion

12 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

FreeMan

I get this error when compile project (-FcUTF8)
....
const
TBS_Captions: array[0..2, 0..1] of string[15] = ( ('Anamnez','ANAMNEZ'), ('Ba??l??
Dosyalar','BA??LI DOSYALAR'), //<-Copy & paste here ->original in source editor('Ba?l? Dosyalar','BA??LI DOSYALAR'),
('Notlar','NOTLAR')

                                                   );

....
Error: Unicodechar/string constants cannot be converted to ansi/shortstring at compile-time

Reply by email

FreeMan
to FreeMan: ? ~ fpc Free Pascal Compiler version 3.1.1 [2015/02/15] for x86_64

fpc svn r29705
lazarus svn r47803
osx yosemite QT x64
reupdate fpc and lazarus then try compile

problem on Turkish chars. "?" "?" "?" if I remove this chars compiled without error. source editors encoding is UTF-8 too. before and now.

FreeMan wrote 6 lines
? ~ fpc Free Pascal Compiler version 3.1.1 [2015/02/15] for x86_64 On 15.02.2015 16:02, Juha Manninen wrote: > What compiler version you have?

Reply by email

FreeMan
to Juha Manninen: Ok, use define -dEnableUTF8RTL. For details see :…

-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]);
Juha Manninen wrote 5 lines
Ok, use define -dEnableUTF8RTL. For details see : http://wiki.freepascal.org/Better_LCL_Unicode_Support#Testing_with_Lazarus Juha

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150215/c9b713b4/attachment.html>

Reply by email

Mattias Gaertner
to FreeMan
Show quoted text 17 lines
-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

Reply by email

Mattias Gaertner
to Mattias Gaertner
Show quoted text 6 lines
On Sun, 15 Feb 2015 17:10:06 +0200 FreeMan wrote: [...] Solutions: a) change the constant to String. b) Put the constant into a unit with system codepage. For example:

c) use codes

s: string[15] = #$C3#$A4#$C3#$B6#$C3#$BC; // ??? as UTF-8

Mattias

Reply by email

FreeMan
to Mattias Gaertner: On Sun, 15 Feb 2015 17:10:06 +0200 The string[15] is a shortstring. You can assign only…

Thank you Mattias,
Solutions A is better for me.
This is work for me
TBS_Captions: array[0..2, 0..1] of string = (
('Anamnez','ANAMNEZ'),('Ba?l? Dosyalar','BA?LI
DOSYALAR'),('Notlar','NOTLAR'));

-FcUTF8 added, have to use this Juha's suggestion directive too? "-dEnableUTF8RTL"

Mattias Gaertner wrote 6 lines
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:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150215/c88c4fd8/attachment-0001.html>

Reply by email

Juha Manninen
to FreeMan
FreeMan wrote
-FcUTF8 added, have to use this Juha's suggestion directive too? "-dEnableUTF8RTL"

Only if you want to use the improved UTF8 support. See the wiki page: http://wiki.freepascal.org/Better_LCL_Unicode_Support

Indeed my suggestion was not relevant for your problem. -dEnableUTF8RTL changes encoding of String type but not ShortString.

However as you have plenty of energy you should define EnableUTF8RTL and test with it.
Remember, it must be in "Additions and Overrides" to affect all dependent packages.
We expect more issues with Windows API calls. They should be added to the "Open issues" section of the wiki page.

Juha

Reply by email

FreeMan
to Juha Manninen: Only if you want to use the improved UTF8 support. See the wiki page:…

Thank you Juha,
I add -dEnableUTF8RTL & -FcUTF8 and I'll not use shortstring, no metter. I can not much detail, but first view is, some message and my application create some folder and that has a Turkish chars, now in message and in created folder name is okey. I mean Turkish chars is view normal now. Some string function can check later.

Juha Manninen wrote 14 lines
Only if you want to use the improved UTF8 support. See the wiki page: http://wiki.freepascal.org/Better_LCL_Unicode_Support Indeed my suggestion was not relevant for your problem. -dEnableUTF8RTL changes encoding of String type but not ShortString. However as you have plenty of energy you should define EnableUTF8RTL and test with it. Remember, it must be in "Additions and Overrides" to affect all dependent packages. We expect more issues with Windows API calls. They should be added to the "Open issues" section of the wiki page. Juha

Reply by email