From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bde6706c124e6eed X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news2.volia.net!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Filenames in Ada Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1653090.31FM62oI6I@linux1.krischik.com> Date: Wed, 23 Nov 2005 19:59:27 +0100 Message-ID: NNTP-Posting-Date: 23 Nov 2005 19:59:18 MET NNTP-Posting-Host: e10020db.newsread4.arcor-online.net X-Trace: DXC=OHcKUfR\YHV8f4>W>BJ_OP:ejgIfPPldTjW\KbG]kaMXFYk:AnJB[C]UA74FhN[DmP[6LHn;2LCV^[ On Wed, 23 Nov 2005 18:36:47 +0100, Martin Krischik wrote: > However, filenames in music collections contain all sort of funny characters > (especially the my wife's music - allmost entirely in Cyrillic) - no big > deal for modern file systems. But a big deal for Ada as it seams. Not only > are all filenames in Ada.Directories of type String - actually all > filenames anywhere are just String. > > How does one deal with modern (utf-8) filenames in Ada? An interesting question! Indeed the file name parameter is of String type. Well, some quick check. The following works fine under Fedora / GNAT: with Ada.Text_IO; use Ada.Text_IO; with Strings_Edit.UTF8.Handling; use Strings_Edit.UTF8.Handling; procedure UTF8_Test is Name : Wide_String := ( Wide_Character'Val (1092) & Wide_Character'Val (1072) & Wide_Character'Val (1081) & Wide_Character'Val (1083) ); File : File_Type; begin Create (File, Out_File, To_UTF8 (Name)); Close (File); end UTF8_Test; If you have Cyrillic code page installed you will see the file name correctly spelt in Russian. No wonder, Fedora Linux is natively UTF-8! 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. > Is there a chance for an add-on package (to late for Ada 2005) or are we > snookered until Ada 2015. 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. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de