Re: [Haskell-cafe] File name encodings

Oh, perhaps you want to 'decode' the string that dirOpenDialog returns. redcom:
Hi Don,
must be doing something wrong.
The messed up string originates from calling Graphics.UI.WX.dirOpenDialog and selecting a directory with Umlauts.
The encode function doesn't seem to help here as it's too far at the end of the chain.
Günther
Am 10.12.2008, 02:45 Uhr, schrieb Don Stewart
: redcom:
Hi,
how can I convert a file name with for example umlauts (ü, ä ... ) into UTF8, or some other format that I can actually use it?
Günther
Using the utf8-string package to encode the file name string.
e.g.
x <- readFile (encode "ኃይሌ ገብረሥላሴ")
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-string

On Tue, 2008-12-09 at 18:17 -0800, Don Stewart wrote:
Oh, perhaps you want to 'decode' the string that dirOpenDialog returns.
redcom:
Hi Don,
must be doing something wrong.
The messed up string originates from calling Graphics.UI.WX.dirOpenDialog and selecting a directory with Umlauts.
This is such a huge can of worms. The Gtk open dialog has two functions for returning the selected file name. One returns a string suitable to use with operating system functions like readFile while the other returns a unicode string suitable to display in the user interface. These need not be the same, or even inter-convertible. On Windows they are identical because it uses unicode for file names, however unix uses byte strings and people sometimes use utf8 and sometimes some other locale. So it's not safe to convert a file name to a unicode string and then back again and expect to be saving the same file. Document editor programs typically remember both strings so that it can save the file again even if displaying the file name was lossy (eg due to locale conversion errors like invalid utf8). Yet another reason why FilePath /= String (except on Windows where it does). Duncan

Duncan Coutts wrote:
Yet another reason why FilePath /= String (except on Windows where it does).
Duncan
Well, it is not a "OS" issue but a "FileSystem" issue. OS X is a Unix, but the main filesystem is HFS+ which has Unicode names, though they use a different normalization. So "FilePath == String" on most OS X systems.
participants (3)
-
ChrisK
-
Don Stewart
-
Duncan Coutts