[Lazarus] UTF8 string handling problem under linux
Mattias Gaertner
nc-gaertnma at netcologne.de
Sun Aug 11 19:55:50 CEST 2013
On Sun, 11 Aug 2013 11:17:16 +0800
Xiangrong Fang <xrfang at gmail.com> wrote:
> Hi All,
>
> I have the following program:
>
> ===============================================================
> procedure TForm1.Button1Click(Sender: TObject);
> begin
> if sd.Execute then begin
> if r.OpenKey('test_utf8', True) then begin
> // r.WriteString('path', UTF8ToSys(sd.FileName));
> r.WriteString('path', sd.FileName);
> r.CloseKey;
> end;
> end;
> end;
>
> procedure TForm1.Button2Click(Sender: TObject);
> begin
> if r.OpenKey('test_utf8', False) then begin
> // ShowMessage('path=' + SysToUTF8(r.ReadString('path')));
> ShowMessage('path=' + r.ReadString('path'));
> r.CloseKey;
> end;
> end;
> ============================================================
>
> It runs OK under windows whether I use SysToUTF8 or not, but on Linux, it
> crashes (SIGSEGV) on the line with r.ReadString.
Please provide a backtrace.
What is r?
What compiler version?
> I wonder what is the correct way to write a program that compile and run
> well under both Windows and Linux?
Usually Linux already has UTF8, so SysToUTF8 does no conversion.
Mattias
More information about the Lazarus
mailing list