tags:

views:

530

answers:

2

Is there a wchar_t version of exec[lv][pe]* (i.e. an exec that uses wchar_t as path and wchar_t as arguments)? In Windows, I can just do CreateProcessW(process, cmdline), but in *nix, I'm stuck (i.e. no pure POSIX equivalent). I'm trying to add UTF-16 support to my program (an autorun).

+4  A: 

There is not. In UNIX, it's customary to use UTF-8 when interacting with the environment.

John Millikin
Is exec[lv][pe]* UTF-8-aware?
That's the beauty of UTF-8 -- they don't have to be. Any functions that operate on NULL-terminated bytes (AKA almost every one) will work with UTF-8.
John Millikin
in Unix, it's customary to use ASCII when interacting with the environment.
hillu
+2  A: 

There is a problem though: the file system on UNIX/Linux is encoding-agnostic. All file names are just "a bunch of bytes"

So if I do a LANG=ja_JAP.EUC_JP, create a file with Japanese name, then I do a LANG=ja_JP.UTF8, when I look at my file name will look like junk, and it will be an invalid UTF-8 string.

You might say: why do that? But imagine you have a system used by hundreds of international users, each of them using Russian/Chinese/Korean/Arabic files, and you have to write a backup application :-(

The "solution" is to ask everybody to set the locale to something.UTF8, but that is just a convention, the system itself does not enforce anything.

Mihai Nita