[Lazarus] UTF8 string handling problem under linux

Xiangrong Fang xrfang at gmail.com
Sun Aug 11 09:47:39 CEST 2013


btw, the problem occur if the input string is CJK.


2013/8/11 Xiangrong Fang <xrfang at gmail.com>

> 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/aee0eb60/attachment-0003.html>


More information about the Lazarus mailing list