Sign in Join

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

Mailing lists / lazarus / 2012-12

OpenDialog, TFileStream and unicode file name

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Krzysztof

Hi,

I have file "01 Amassakoul 'N'Te?ne?re?.mp3" (don't know what language it is)

This code work on linux:

  if OpenDialog1.Execute then
  begin
    ShowMessage(GuessEncoding(OpenDialog1.FileName));
    f := TFileStream.Create(OpenDialog1.FileName,fmOpenRead);
    try
    finally
      f.Free;
    end;
  end;

But on windows I get error "Unable to open file....". GuessEncoding return "UTF8" so I tried to convert it by UTF8ToSys, UTF8ToCP1252 but same error. I read http://wiki.freepascal.org/LCL_Unicode_Support but have no idea what to do

Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121220/6193ca91/attachment.html>

Reply by email

Mattias Gaertner
to Krzysztof
Show quoted text 22 lines
Hi, I have file "01 Amassakoul 'N'Te?ne?re?.mp3" (don't know what language it is) This code work on linux: if OpenDialog1.Execute then begin ShowMessage(GuessEncoding(OpenDialog1.FileName)); f := TFileStream.Create(OpenDialog1.FileName,fmOpenRead); try finally f.Free; end; end; But on windows I get error "Unable to open file....". GuessEncoding return "UTF8" so I tried to convert it by UTF8ToSys, UTF8ToCP1252 but same error. I read http://wiki.freepascal.org/LCL_Unicode_Support but have no idea what to do

Instead of TFileStream try using TFileStreamUTF8 of unit lazutf8classes.

Mattias

Reply by email