comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Filenames in Ada
Date: Thu, 24 Nov 2005 21:49:43 +0100
Date: 2005-11-24T21:49:35+01:00	[thread overview]
Message-ID: <hcj87m4mv37e$.1uj3pzelawsm9.dlg@40tude.net> (raw)
In-Reply-To: 24636991.vKdJMLXJE2@linux1.krischik.com

On Thu, 24 Nov 2005 20:13:01 +0100, Martin Krischik wrote:

> Dmitry A. Kazakov wrote:
> 
>> On Wed, 23 Nov 2005 18:36:47 +0100, Martin Krischik wrote:
>> 
> Find the code at:
> http://cvs.sourceforge.net/viewcvs.py/wikibook-ada/demos/Source/make_m3u.adb?only_with_tag=HEAD&view=markup
> 
> at let it loose at a directory with Cyrillic filenames.

It works perfectly well. Ada.Directories returns file names as-is. One
don't need to change anything:

   while More_Entries (Search_Artist) loop
      Get_Next_Entry (Search_Artist, Artist_Entry);
      declare
         Artist : String renames Simple_Name (Artist_Entry);
             -- This is UTF-8 encoded under Linux
      begin
         if (  Artist /= "." -- ASCII-7 is UTF-8!
            and then
               Artist /= ".."
            and then
               Artist /= "Folder Settings"
            )
         then
            Put_Line (Artist); -- Outputs UTF-8
         end if;
      end;
   end loop;

>> Though it cannot work under Windows, because GNAT run-time translates
>> Create into some CreateFileA Windows API. Moreover Windows is UTF-16. So
>> there is no chance for Ada.Text_IO.Create. I presume one could directly
>> use CreateFileW from Windows API with a Wide_String file name, but that's
>> another story.
> 
> I fear that is the only option available. But how to turn the Windows
> filehandle into a Ada one...

I'm afraid there is no other way than to ask ACT 1) to use xxxW stuff for
all file operations and 2) to translate String file names from UTF-8 to
UTF-16 when it goes down to Windows and from UTF-16 to UTF-8 when it goes
back.

>> I don't see any great problem here. I would add UTF-8 variants for all
>> calls where a file name is mentioned. We could even switch from Latin-1 to
>> UTF-8. This seems to be independent on Text_IO vs. Wide_Text_IO issue.
> 
> I am not sure. There are quite a few OS dependent functions involved here.

It cannot be portable.

Well, does VMS still use Radix-50 for file names? (:-)) That's wise!

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2005-11-24 20:49 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-23 17:36 Filenames in Ada Martin Krischik
2005-11-23 18:09 ` Martin Dowie
2005-11-24 19:16   ` Martin Krischik
2005-11-23 18:59 ` Dmitry A. Kazakov
2005-11-24 19:13   ` Martin Krischik
2005-11-24 20:49     ` Dmitry A. Kazakov [this message]
2005-11-24 21:23       ` Larry Kilgallen
2005-11-25  7:12       ` krischik
2005-11-25 12:25         ` [OT] VMS ODS-5 filesystems, was: " Simon Clubley
2005-11-25 18:01           ` Martin Krischik
2005-11-25 18:27             ` Georg Bauhaus
2005-11-25 19:54               ` Martin Krischik
     [not found]             ` <gjqeo157udsnbfuq8ak4dosf6nep5fomss@4ax.com>
2005-11-27  9:31               ` [OT] VMS DCL prompt, was: " Martin Krischik
2005-11-30  0:16                 ` [OT] Administrator accounts (was: VMS DCL prompt) Björn Persson
2005-11-30  4:23                   ` Larry Kilgallen
2005-11-23 22:18 ` Filenames in Ada Randy Brukardt
2005-11-24  3:21   ` Silly question about strings (was: Filenames in Ada) Steve
2005-11-24  4:58     ` Larry Kilgallen
2005-11-24  9:15       ` Martin Dowie
2005-11-24 11:30         ` Silly question about strings Brian May
2005-11-24 13:06         ` Silly question about strings (was: Filenames in Ada) Larry Kilgallen
2005-11-29  3:17     ` Randy Brukardt
2005-11-29  5:53       ` tmoran
2005-11-29 21:48         ` Randy Brukardt
2005-11-30  0:15         ` Björn Persson
2005-11-24 19:05   ` Filenames in Ada Martin Krischik
2005-11-25  6:54     ` Martin Dowie
2005-11-26  1:22 ` Björn Persson
2005-11-27 10:21   ` Martin Krischik
2005-11-30  0:13     ` Björn Persson
2005-12-01  6:59       ` Martin Krischik
2005-12-03  1:07         ` Björn Persson
2005-12-14  6:59         ` Dave Thompson
2005-12-15 20:23           ` Martin Krischik
2005-12-17  0:22             ` program privileges (was: Filenames in Ada) Georg Bauhaus
2005-12-17 16:59             ` Filenames in Ada Simon Wright
2005-12-17 23:18               ` Larry Kilgallen
2005-12-18 13:30                 ` privileges in Unix and VMS (was: Filenames in Ada) Björn Persson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox