[Lazarus] OpenDialog, TFileStream and unicode file name

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Dec 20 09:42:04 CET 2012


On Thu, 20 Dec 2012 09:24:20 +0100
Krzysztof <dibo20 at wp.pl> wrote:

> Hi,
> 
> I have file "01 Amassakoul 'N'Ténéré.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




More information about the Lazarus mailing list