caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] How do I create files with UTF-8 file names?
@ 2004-09-11  9:01 Mattias Waldau
  2004-09-15 12:37 ` Yamagata Yoriyuki
  2004-09-15 14:18 ` Peter Jolly
  0 siblings, 2 replies; 5+ messages in thread
From: Mattias Waldau @ 2004-09-11  9:01 UTC (permalink / raw)
  To: caml-list

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.

Or should I solve this problem by talking directly to the Win32-api? Has 
anyone done this?

-- mattias

-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] How do I create files with UTF-8 file names?
  2004-09-11  9:01 [Caml-list] How do I create files with UTF-8 file names? Mattias Waldau
@ 2004-09-15 12:37 ` Yamagata Yoriyuki
  2004-09-15 12:54   ` Mattias Waldau
  2004-09-15 14:18 ` Peter Jolly
  1 sibling, 1 reply; 5+ messages in thread
From: Yamagata Yoriyuki @ 2004-09-15 12:37 UTC (permalink / raw)
  To: mattias.waldau; +Cc: caml-list

From: Mattias Waldau <mattias.waldau@abc.se>
Subject: [Caml-list] How do I create files with UTF-8 file names?
Date: Sat, 11 Sep 2004 11:01:05 +0200

> 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.

On my Debian/Linux machine, I can make a file with a Japanese (EUC-JP)
name just like an ASCII named file.

# let c = open_out "\164\198\164\185\164\200";;
val c : out_channel = <abstr>
# output_string;;
- : out_channel -> string -> unit = <fun>
# output_string c "\164\198\164\185\164\200";;
- : unit = ()
# close_out c;;
- : unit = ()

$ ls
てすと

Or am I missing something?

--
Yamagata Yoriyuki

-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] How do I create files with UTF-8 file names?
  2004-09-15 12:37 ` Yamagata Yoriyuki
@ 2004-09-15 12:54   ` Mattias Waldau
  2004-09-15 13:27     ` Yamagata Yoriyuki
  0 siblings, 1 reply; 5+ messages in thread
From: Mattias Waldau @ 2004-09-15 12:54 UTC (permalink / raw)
  To: Yamagata Yoriyuki; +Cc: caml-list

On windows I will get a file called "\164\198\164\185\164\200" instead
of the actual name.

-- Mattias


Yamagata Yoriyuki wrote:

> From: Mattias Waldau <mattias.waldau@abc.se>
> Subject: [Caml-list] How do I create files with UTF-8 file names?
> Date: Sat, 11 Sep 2004 11:01:05 +0200
> 
> 
>>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.
> 
> 
> On my Debian/Linux machine, I can make a file with a Japanese (EUC-JP)
> name just like an ASCII named file.
> 
> # let c = open_out "\164\198\164\185\164\200";;
> val c : out_channel = <abstr>
> # output_string;;
> - : out_channel -> string -> unit = <fun>
> # output_string c "\164\198\164\185\164\200";;
> - : unit = ()
> # close_out c;;
> - : unit = ()
> 
> $ ls
> てすと
> 
> Or am I missing something?
> 
> --
> Yamagata Yoriyuki
> 
> 


-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] How do I create files with UTF-8 file names?
  2004-09-15 12:54   ` Mattias Waldau
@ 2004-09-15 13:27     ` Yamagata Yoriyuki
  0 siblings, 0 replies; 5+ messages in thread
From: Yamagata Yoriyuki @ 2004-09-15 13:27 UTC (permalink / raw)
  To: mattias.waldau; +Cc: caml-list

From: Mattias Waldau <mattias.waldau@abc.se>
Subject: Re: [Caml-list] How do I create files with UTF-8 file names?
Date: Wed, 15 Sep 2004 14:54:19 +0200

> On windows I will get a file called "\164\198\164\185\164\200" instead
> of the actual name.

Your Windows probably does not recognize EUC-JP, so if you input my
example literally, it would not be displayed correctly.  Try
"\227\129\166\227\129\153\227\129\168" (UTF-8 encoded string) if you
configured your system to use UTF-8, or some Nordic characters.

--
Yamagata Yoriyuki

-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] How do I create files with UTF-8 file names?
  2004-09-11  9:01 [Caml-list] How do I create files with UTF-8 file names? Mattias Waldau
  2004-09-15 12:37 ` Yamagata Yoriyuki
@ 2004-09-15 14:18 ` Peter Jolly
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Jolly @ 2004-09-15 14:18 UTC (permalink / raw)
  To: mattias.waldau; +Cc: caml-list

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-09-15 14:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-11  9:01 [Caml-list] How do I create files with UTF-8 file names? 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 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).