caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Peter Jolly <peter@jollys.org>
To: mattias.waldau@abc.se
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] How do I create files with UTF-8 file names?
Date: Wed, 15 Sep 2004 15:18:00 +0100	[thread overview]
Message-ID: <41484F18.8050108@jollys.org> (raw)
In-Reply-To: <4142BED1.7050604@abc.se>

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


      parent reply	other threads:[~2004-09-15 14:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-11  9:01 Mattias Waldau
2004-09-15 12:37 ` Yamagata Yoriyuki
2004-09-15 12:54   ` Mattias Waldau
2004-09-15 13:27     ` Yamagata Yoriyuki
2004-09-15 14:18 ` Peter Jolly [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41484F18.8050108@jollys.org \
    --to=peter@jollys.org \
    --cc=caml-list@inria.fr \
    --cc=mattias.waldau@abc.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).