Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-05

TSynEdit.Lines.LoadFromFile and UTF8

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

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.

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.

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

B.t.w. the Lazarus IDE is able to this file, and so is a TStringListUtf8 instance.

Bart

Reply by email

Mattias Gaertner
to Bart
Show quoted text 11 lines
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.

Show quoted text 6 lines
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

Reply by email

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

I've been unable to find that.
I knew LoadFromFile had to be overloaded somewhere...

Change syneditlines.pas TFileStream to TFileStreamUTF8. I don't have Windows here, so I can not test.

Thanks for pointing me in the right direction.

I will look into it and send a patch in the bugtracker. (I don't have commit rights in synedit.)

Bart

Reply by email