Unicode paths and iostream

Recommended Posts

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]

Share on other sites
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.

Share on other sites
Looks like I'm out of luck. Thanks anyway.

Share on other sites
... or you can join the rest of the world and use the methods that SiCrane detailed. They work, just try it.

Share on other sites
wcstombs is lossy. It will only work for whatever subset of names are representable in the locale.

Share on other sites
I just found out about STLport 5.0 beta's feature to open fstreams from a HANDLE. This looks just like what I need.

Create an account

Register a new account

• Forum Statistics

• Total Topics
628391
• Total Posts
2982419

• 10
• 9
• 19
• 24
• 11