28 #ifndef CAST_UNICODE_H 29 #define CAST_UNICODE_H 38 INLINE std::wstring
widen(
const std::string& str) {
39 std::wostringstream wstm;
40 const std::ctype< wchar_t >& ctfacet =
41 std::use_facet< std::ctype< wchar_t > >(wstm.getloc());
43 for (
size_t i = 0; i < str.size(); ++i) {
44 wstm << ctfacet.widen(str[i]);
50 INLINE std::string
narrow(
const std::wstring& str) {
51 std::ostringstream stm;
52 const std::ctype< char >& ctfacet =
53 std::use_facet< std::ctype< char > >(stm.getloc());
55 for (std::size_t i = 0; i < str.size(); ++i) {
56 stm << ctfacet.narrow(str[i], 0);
62 #endif // CAST_UNICODE_H INLINE std::string narrow(const std::wstring &str)
Cast a std::wstring into a std::string.
INLINE std::wstring widen(const std::string &str)
Cast a std::string into a std::wstring.
Unicode helper functions.