From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA28979; Wed, 15 Sep 2004 16:16:40 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA29834 for ; Wed, 15 Sep 2004 16:16:38 +0200 (MET DST) Received: from cirrus.purplecloud.com (cirrus.purplecloud.com [217.158.94.220]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i8FEGaCM022903 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 15 Sep 2004 16:16:38 +0200 Received: (qmail 95817 invoked from network); 15 Sep 2004 14:16:35 -0000 Received: from 81-86-133-45.dsl.pipex.com (HELO ?192.168.1.176?) (81.86.133.45) by smtp.purplecloud.net with AES256-SHA encrypted SMTP; 15 Sep 2004 14:16:35 -0000 Message-ID: <41484F18.8050108@jollys.org> Date: Wed, 15 Sep 2004 15:18:00 +0100 From: Peter Jolly Reply-To: caml-list User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) X-Accept-Language: en-us, en MIME-Version: 1.0 To: mattias.waldau@abc.se CC: caml-list Subject: Re: [Caml-list] How do I create files with UTF-8 file names? References: <4142BED1.7050604@abc.se> In-Reply-To: <4142BED1.7050604@abc.se> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 41484EC4.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 mattias:01 waldau:01 filenames:01 ocaml's:01 api:01 ocaml's:01 afaik:01 encoded:02 string:03 wrote:03 interface:03 interface:03 library:03 probably:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Mattias Waldau wrote: > I have a filename as an UTF-8 encoded string. I need to be able to > handle strange chars like accents, Asian chars etc. > > Is there any way to create a file with that name? I only need it on Win32. Windows uses UTF-16 for filenames, but provides a non-Unicode interface for legacy applications; the standard open() function that OCaml's open_out wraps appears to use the legacy interface. The precise codepage this uses is system-dependent, and AFAIK there's no way for a program to determine what it is without calling out to the Win32 API, but you can be pretty sure it won't be UTF-8. In other words, there is no reliable way to use a filename containing non-ASCII characters with OCaml's standard library. > Or should I solve this problem by talking directly to the Win32-api? This is probably the best solution. A combination of CreateFileW() and MultiByteToWideChar() should do what you want. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners