[Lazarus] UTF8 string handling problem under linux

Xiangrong Fang xrfang at gmail.com
Sun Aug 11 05:17:16 CEST 2013


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.

I wonder what is the correct way to write a program that compile and run
well under both Windows and Linux?

Thanks,
Shannon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130811/c7a5b99e/attachment-0002.html>


More information about the Lazarus mailing list