Unicode paths and iostream

Started by
4 comments, last by demonkoryu 18 years, 5 months ago
Hi, I'm desperatly looking for something that allows me to use Unicode path names with iostreams. Strangely enough, even boost::filesystem does not support them, and neither does WinSTL. An example of what I'd like to do follows:

std::wstring path( L"./file.ext" );
std::wifstream file( path.c_str() );
The closest I can get is with the help of the ICU, however even this only extends C-style stdio to handle unicode paths. Well, I am developing a Win32 program, so I could just use the CreateFileW function, but that doesn't fit with the rest of my program, which tries to rely only on SC++L iostreams, boost and winSTL. How do you handle Unicode in your path names? [Edited by - Konfusius on November 25, 2005 8:37:58 AM]
Advertisement
Unfortuntaly if you want to stick with the standard library streams you need to use narrow characters as file names. You can use wcstombs() to narrow the wide character streams, or if you're feeling adventurous, the narrow() member function of the ctype facet of a locale.
Looks like I'm out of luck. Thanks anyway.
... or you can join the rest of the world and use the methods that SiCrane detailed. They work, just try it.
wcstombs is lossy. It will only work for whatever subset of names are representable in the locale.
-Mike
I just found out about STLport 5.0 beta's feature to open fstreams from a HANDLE. This looks just like what I need.

This topic is closed to new replies.

Advertisement