[Lazarus] TSynEdit.Lines.LoadFromFile and UTF8

Mattias Gaertner nc-gaertnma at netcologne.de
Thu May 30 20:53:09 CEST 2013


On Thu, 30 May 2013 20:44:25 +0200
Bart <bartjunk64 at gmail.com> wrote:

> Hi,
> 
> I'm a bit confused here.
> I have a TSynEdit.
> If I do SynEdit1.Lines.LoadFromFile(OpenDialog1.FileName) this
> succeeds on filenames with unicode characters within the current
> codepage.
> No need to use Utf8ToSys like it is necessary for TMemo.Lines.LoadFromFile.
> 
> AFAICS the lines property of a TSynEdit is of type TStrings, just like
> the Lines of TMemo.

Yes, but it is a TSynEditLines, which overloads LoadFromFile and does
UTF8ToSys itself. It should be changed to use the UTF8
file functions instead.

 
> Even while I don't understand this, I can live with it.
> TSynEdit needs no Utf8ToSys for loading, OK.
> 
> But wait, if a filename has unicode characters outside the current
> codepage (I have a folder with some asian charcters in the name), this
> fails al of the sudden.

Yes.

 
> So, now I need to know the why, or else I cannot fix it.

Change syneditlines.pas TFileStream to TFileStreamUTF8.
I don't have Windows here, so I can not test.
 
> B.t.w. the Lazarus IDE is able to this file, and so is a
> TStringListUtf8 instance.


Mattias




More information about the Lazarus mailing list