From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 59698BBAF for ; Thu, 14 Oct 2010 12:32:38 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ak8FAMN4tkxQW+UMgWdsb2JhbACTLI12FQEBFiIiu32FSASKQQ X-IronPort-AV: E=Sophos;i="4.57,329,1283724000"; d="scan'208";a="81087375" Received: from lo.gmane.org ([80.91.229.12]) by mail1-smtp-roc.national.inria.fr with ESMTP; 14 Oct 2010 12:32:38 +0200 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P6L6t-0003wE-0y for caml-list@inria.fr; Thu, 14 Oct 2010 12:32:31 +0200 Received: from avelizy-155-1-41-219.w83-204.abo.wanadoo.fr ([83.204.200.219]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Oct 2010 12:32:31 +0200 Received: from sylvain by avelizy-155-1-41-219.w83-204.abo.wanadoo.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 14 Oct 2010 12:32:31 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Sylvain Le Gall Subject: Re: Unicode, update Date: Thu, 14 Oct 2010 10:32:19 +0000 (UTC) Message-ID: References: X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: avelizy-155-1-41-219.w83-204.abo.wanadoo.fr User-Agent: slrn/pre1.0.0-18 (Linux) X-Spam: no; 0.00; le-gall:01 steckler:01 steck:01 ocaml:01 camomile:01 ocaml:01 wrote:01 parsing:01 functions:01 functions:01 exceptions:01 primitives:01 primitives:01 filenames:02 filenames:02 Hello, On 14-10-2010, Paul Steckler wrote: > A couple of weeks ago or so, I asked about using OCaml file primitives > with the Camomile library for Unicode > on Windows. I thought I'd update people on the list about my > resolution of these issues. > > I decided to make the application UTF-8 throughout, so that the string > type always means UTF-8 -- OK, there > are a few exceptions to that rule. The SQLite3 library already deals > with UTF-8 in a graceful way, The same is > true for the C/C++ parsing library I'm using. That leaves the OCaml > library procedures, like open_in and open_out, > which definitely don't handle Unicode filenames on Windows. > > I took the OCaml sources and made modified versions of functions, like > file_exists, open_in, and so on, > that convert filenames from UTF-8 to UTF-16 and then used "wide" > versions of the underlying Win32 > primitives. In some cases, I had to convert UTF-16 back to UTF-8. > The Win32 functions MultiByteToWideChar > and WideCharToMultiByte handle those conversions nicely. I link in > these new functions, named > file_exists_win32, open_in_win32, etc., and everything works a treat. > Would it be possible to publish them as an external library? Thanks for the update Sylvain Le Gall