On Mar 13, 2014, at 6:04 PM, Rick Yorgason wrote:
Martin Owens <doctormo@...360...> writes:
Jon Cruz: What say you, std::string or std::ustring for paths?
Lurker here, but the soon-to-be-canonical solution is std::path, which is currently known as boost::path or std::tr2::path if your compiler is new enough.
The only surprise you need to be aware of, if your string bits are stored as utf8 rather than the native narrow type, is that you need to use:
filesystem::detail::utf8_codecvt_facet utf8; path(myUtf8String, utf);
We do hit another issue.
On Windows, there is no safe narrow string encoding for paths. If one uses only ASCII characters to name files and folders, things might appear to work. However, as soon as you encounter something not in the current Windows ANSI Code Page, that falls apart.
One classic example is the Japanese student studying in Germany, where the default local is German with an ANSI Code Page of 1252, whereas the user's home directory is his name... which is composed of Kanji that don't map to CP-1252.