Entwickler-Ecke

Sonstiges (Delphi) - How to read filenames based on greek charcters


larshgf - Mi 19.10.05 19:34
Titel: How to read filenames based on greek charcters
Hi,

I'm using Delphi 5. In order to programmtically change the local language my PC is using I have looked on the function SetThreadLocale, and after surfing the web I was recommended to start my application in this way in order to obtain the greek language:


Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
program Mp3_TagEdit_Prj;

uses
  Forms,
  Windows, **
  SysUtils, **
  MainUnit in 'MainUnit.pas' {MainForm};

{$R *.RES}

begin
  SetThreadLocale($0408); **
  GetFormatSettings; **
  Application.Initialize; **

  Application.CreateForm(TMainForm, MainForm);
  Application.Run;
end.

(the programlines with ** is added to my standard programstart)

But the problem is that this does not functionate. When I try to show the content of a folder in FileListBox everything works fine as long as the filename is made up of english characters, but if the folder contains filenames mad up of greek characters I get an I/O error 123 men which means that the file cannot be opened - in another way FileListBox is not able to read these greek filenames.

In my program all fonts are set to GREEK_CHARSET.

But I still program in Delphi 5, and I wonder if I would get rid of this problemg by using the newest Delphi 2005 instead ??

I think it is peculiar that my Windows XP can read greek filenames without problems. Likewise my mp3-program
(MediaMonkey) can read these files too without any problems

[the following "labels" from windows XP is my own translation to english from the danish version and is probably not exactly right]
If I go in Windows XP "Control Panel" and open "International and language settings", and then under the tab "Advanced" under "Language with non-unicode programs" set the language to Greek and RESTART my PC
- then my FileListBox can read the greek filenames.
But as mentioned earlier - I would like to be able to do this programmatically, and not by change a setting in Windows and restart my PC.

So finally my question is:
Do you think thar using Delphi 2005 instead of Delphi 5 will solve the problem?? Or could there be any other solutions/suggestions to solve the problem??

Hoping very much for an answer

KindRegards
Lars

Moderiert von user profile iconChristian S.: Added delphi tags


Bernhard Geyer - Do 20.10.05 22:53

You need the TNTWare-Controls (http://www.tntware.com/delphicontrols/unicode/downloads.htm) that has Unicode-Enabled File-Handling-Routines. You also can use this control to display the greek characters without setting Thread-Local or working with codepages/Charsets.


larshgf - Do 20.10.05 23:05

I have downloaded and tried to use the TNTWare-Controls in order to se my greek files. But it did not work right. I tried the ususal FindFirst/FindNext funktions in Delphi and tried to place the filenames into a TNTListbox. But nothing happened. Where is the file handling routines in the TNT downlad? Can you give me a hint or maybe a short example?

Best Regards
Lars


Bernhard Geyer - Fr 21.10.05 08:25

user profile iconlarshgf hat folgendes geschrieben:
I tried the ususal FindFirst/FindNext funktions in Delphi and tried to place the filenames into a TNTListbox. But nothing happened.

You need to use WideFindFirst, WideFindNext, WideFindClose in TNTSysUtils to do this FindFirst/FindNext are only ANSI-Functions.[/quote]


digi_c - Fr 21.10.05 08:25

If I understood Bernhard right than the TNTWare Componts have their own Filehandling routines in order to around the limited native filereading functions of Delphi :/


larshgf - Fr 21.10.05 09:14

My huge lack of knowledge on this unicode subject is certainly revealed....;-). But I'm sure I will found out how to implement the Wide-functions in my program via TNTSysUtils.
Thank you very much for your answers, it has been a great help for me!!

Lars