tags:

views:

736

answers:

2

Is there a standard way to do an fopen with a unicode string file path?

+2  A: 

This is a matter of your current locale. on my system, which is unicode enabled, file paths will be in unicode. I'm able to detect this by means of the locale command:

$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"

The encoding of file paths is normally set system wide, so if your file path is not in the system's locale, you will need to convert it, perhaps by means of the iconv library.

TokenMacGuy
+3  A: 

In *nix, you simply use the standard fopen (see more information in reply from TokeMacGuy, or in this forum) In windows, you can use _wfopen, and then pass a unicode string (for more information, see MSDN).

As there is no real common way, I would wrap this call in a macro, together with all other system-dependent functions.

Roberto Liffredo