German Umlaute with Lazarus

Hi
I build the same App as with Delphi and in Lazarus there are no German Umlaute
( like äöü ), there are replaced with a ?.
If i access the Database form Delphi it looks normal.

Did anybody have the same Problem?

Manfred

Are you using AnsiString or WideString fields? Essentially, whenever you’re using 8-byte strings, using any characters over #127 is a gamble, and depends on what codepage your database and your app are on — which might or might work, but when it does, it should be considered an accident ;).

Hi mh

Are you using AnsiString or WideString fields?

I am using WideString fields.
My connectin string is:

mysql.net ID=ga_test;Password=secret; convert zero datetime=True;

With the Schema Modeler the Data look also ok.
I did also ad CharSet=utf8; to the connection string with no change.

The Connection String in the App looks like:

RelativityConnectionString: String = ‘User Id=“data_user”;Password=“secret”;Domain=“TEST”;Schema=“admin”;CharSet=utf8;’;

PS: The Password and the Schema Data are fake :wink:

Shalom
Manfred

Hm, so this is a .NET server (or Relativity?) with a Delphi vs FPC client? If the fields are set up as WideString, that this sounds like something the DA/Delphi team needs to look at, client side. I’ll make sure this gets to the right person and someone gets back to you asap.

I use a Relativity Server with Lazarus as a Client.
Delphi works.
Thanks

1 Like

this is problem in fpc itself.
this simple testcase will fail:

program a;
{$MODE DELPHI}
uses
  SysUtils, DB, memds;
var
  mem: TMemDataset;
  str, fld: WideString;
  s: string;
begin
  str := widechar(#$00E4) + widechar(#$00F6) + widechar(#$00FC); //   'äöü';
  mem := TMemDataset.Create(nil);
  try
    mem.FieldDefs.Add('fld1', ftWideString, 20);
    mem.Open;
    mem.Insert;
    mem.fields[0].asWideString := str;
    mem.post;
    fld := mem.fields[0].AsWideString;
    if fld <> str then s := 'test is failed'  else  s := 'test is passed';
    writeln(s);
  finally
    mem.Free;
  end;
end.

Hi
Thank you for your Replay…
Will look forward how i can solve this.

Have a nice Weekend.
Shalom
Manfred

Hi again

found out that with this Code ( under Lazarus 1.4 ) i can convert the Umlaute into a correct value:

procedure Tfrm_hotel.idChange(Sender: TObject);
var
  test_string :String;
begin
    test_string:= AnsiToUTF8(DM_hotel.tbl_hotel.FieldByName('NAME').AsString);
end;    

Of course i could to this on every Edit field… but this seems a little unproductive… :relieved:
Hope there is a way to do this in a central place…

Thank’s for any advice.

Shalom
Manfred

You can create a shared function like

function GetStringValue(aTable: TDADataTable; aFieldName: String):String;
begin
  result := AnsiToUTF8(aTable.FieldByName(aFieldName).AsString);
end;

procedure Tfrm_hotel.idChange(Sender: TObject);
var
  test_string :String;
begin
    test_string:= GetStringValue(DM_hotel.tbl_hotel,'NAME');
end;

it won’t solve current problem, but will allow to update code only in one place (GetStringValue) when proper solution will be found.

Hi again

Did quite some “research” on this Topic.
It lookls like the Combination of Lazarus + RemObjekts do a 2times UTF8 covertion.
One time to much.
Since when i generate Data in the Lazarus App:

Test öäü éàèç

Lazarus can read this Data as:

Test öäü éàèç

But in the Database the Entry is:

Test öäü éÃ*èç

When there are Data already in the Database Lazarus and RemObjet read it not correct, since the Data are in the correct way in the Database. ( Not inserted by Lazarus )
These Data can be read with Delphi and RemObjects correctly.

I did also get some Feedback from a Lazarus Developer who is Developing a Database Tool that Lazarus itself has no Problem with UT8. ( It was the Developer of IBExpert http://www.ibexpert.net/ibe/index.php?n=Main.IBExpert

I realy like RemObject and it would be great if this could be solved. :blush:

In the Delphiprais ( a German speaking Forum ) i also started a Post to get help for this “Lazarus” Problem. http://www.delphipraxis.net/186609-umlaute-lazarus-1-4-2-mit-datenbank-2.html#post1316122

Hi again

Did some additional research.
I setup zeos and testet my MySQL Database with a normal TDBGrid and it works.
The Umlaute are there.( Please see the Attached Picture )
IMHO Lazarus has no Problem with Special Characters. ( Like öäü èàé )

It would be Great if this Problem could be solved.

Thank you in advance
Manfred

I’ve tried to compile my testcase (from this topic) with FPC 3.1.1 and it is still failed:(

Hi EvgenyK

Thank you for your Replay.
I use Lazarus 1.4.2 stable with FPC 2.6.4 the normal official Version from the Website.
http://www.lazarus-ide.org/

I can compile your code and get the result: test is passed :wink:

Crosspost: Crosspost: Cannot compile Application in Delphi XE4 and Lazarus

Hi again just found out that there is a new Version of RemObjects SDK for Delphi - 8.3.93.1183.exe since Mon, Sep 21, 2015.
With this Version there is a general Problem.
I did post that already here:
http://talk.remobjects.com/t/dataabstract-beta-thu-sep-3-2015-with-lazarus-problems/6820

So with the newest Version i cannot compile at all…
With the Version RemObjects Data Abstract for Delphi - 8.3.91.1167 it was fine. :wink:

what switches you are used? I’ve tried
{$mode delphiunicode}
{$ModeSwitch UnicodeStrings}
{$codepage utf8}
and it still fails

Good Morning EvgenyK

I did use no switches at all.
Just a plain empty Project and copy & paste your code.
I attached the sample Project for you. If i can help you please let me know.

Shalom
Manfredtest.zip (1.7 KB)

hmm, it still doesn’t work for me.
tested with

lazarus-1.4.2-fpc-2.6.4-win64.exe 	2015-07-12 	114.2 MB 	

test_exe.zip (178.6 KB)

I’ve added

  Write ('This program was compiled at ',{$I %TIME%});
  Writeln (' on ',{$I %DATE%});
  Writeln ('Compiler version: ',{$I %FPCVERSION%});
  Writeln ('Target CPU: ',{$I %FPCTARGET%});
  writeln ('');

It does compile here:

program test;
{$MODE DELPHI}
uses
  SysUtils, DB, memds;
var
  mem: TMemDataset;
  str, fld: WideString;
  s: string;
begin
  str := widechar(#$00E4) + widechar(#$00F6) + widechar(#$00FC); //   'äöü';
  mem := TMemDataset.Create(nil);
  try
    mem.FieldDefs.Add('fld1', ftWideString, 20);
    mem.Open;
    mem.Insert;
    mem.fields[0].asWideString := str;
    mem.post;
    fld := mem.fields[0].AsWideString;
    if fld <> str then s := 'test is failed'  else  s := 'test is passed';
    Write ('This program was compiled at ',{$I %TIME%});
    Writeln (' on ',{$I %DATE%});
    Writeln ('Compiler version: ',{$I %FPCVERSION%});
    Writeln ('Target CPU: ',{$I %FPCTARGET%});
    writeln ('');
    writeln(s);
  finally
    mem.Free;
  end;
end.  


I’ve the same version of Lazarus.
Probably it depends on current language for non-Unicode programs so it isn’t correct unicode support.
try to change it with locale that doesn’t support German Umlaute and retest.

Did try it with english ( Britan ) language for non-Unicode programs. and it worked…