Recent

Author Topic: [solved] TFileStream.LoadFromFile with unicode name  (Read 3761 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2401
    • UVviewsoft
[solved] TFileStream.LoadFromFile with unicode name
« on: March 01, 2015, 12:26:57 pm »
I cannot load unicode filename via TFilestream.Loadfromfile. How to do it right? 

Code: [Select]
with OpenDialog1 do
begin
  if not Execute then Exit;
  s:= Filename;
  with TFileStream.Create(s, ....) do //Runtime error for unicode
  ...
....

How to pass utf8 name to stream?
« Last Edit: March 01, 2015, 12:58:09 pm by Alex22 »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: TFileStream.LoadFromFile with unicode name
« Reply #1 on: March 01, 2015, 12:34:57 pm »
I cannot load unicode filename via TFilestream.Loadfromfile. How to do it right? 

You can now :
  http://wiki.lazarus.freepascal.org/Better_Unicode_Support_in_Lazarus
Please test this new feature and report possible problems.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Bart

  • Hero Member
  • *****
  • Posts: 5288
    • Bart en Mariska's Webstek
Re: TFileStream.LoadFromFile with unicode name
« Reply #2 on: March 01, 2015, 12:45:12 pm »
Use TFileStreamUtf8 (in unit LazUtf8Classes), it properly converts the UTF8 encoded filename to widestring and uses the widestring API version to create the file.

The solution from Juha works only with fpc trunk (AFAIK).

Bart

AlexTP

  • Hero Member
  • *****
  • Posts: 2401
    • UVviewsoft
Re: TFileStream.LoadFromFile with unicode name
« Reply #3 on: March 01, 2015, 12:57:54 pm »
Bart: it 's what needed.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: TFileStream.LoadFromFile with unicode name
« Reply #4 on: March 01, 2015, 03:00:46 pm »
The solution from Juha works only with fpc trunk (AFAIK).

Also with 3.x branch which is very stable already. Unfortunately there is no FPC 3.0RC1 yet.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Bart

  • Hero Member
  • *****
  • Posts: 5288
    • Bart en Mariska's Webstek
Re: TFileStream.LoadFromFile with unicode name
« Reply #5 on: March 01, 2015, 05:57:46 pm »
The solution from Juha works only with fpc trunk (AFAIK).

Also with 3.x branch which is very stable already. Unfortunately there is no FPC 3.0RC1 yet.

[nitpick]
fpc 3.x = fpc trunk (ATM)
[/nitpick]

 O:-)

Bart

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4467
  • I like bugs.
Re: TFileStream.LoadFromFile with unicode name
« Reply #6 on: March 01, 2015, 06:16:50 pm »
fpc 3.x = fpc trunk (ATM)

Ok, 3.x was not very accurate. I meant fixes 3.0, this one :
  http://svn.freepascal.org/svn/fpc/branches/fixes_3_0/
It reports 3.0.1 as its version and will soon (?) become fpc 3.0. It is very stable at least in my tests.

Trunk is now version 3.1.1. Other branches were merged into it after 3.0 was branched. It is NOT stable right now.

I hope we get fpc 3.0 RC1 soon. It would make installing and testing easier for many people.
I understand the build process is a big burden for fpc project because they support so many targets.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

 

TinyPortal © 2005-2018