30 #ifndef CAST_UNICODE_H 31 #define CAST_UNICODE_H 40 INLINE std::wstring
widen(
const std::string& str) {
41 std::wostringstream wstm;
42 const std::ctype< wchar_t >& ctfacet =
43 std::use_facet< std::ctype< wchar_t > >(wstm.getloc());
45 for (
size_t i = 0; i < str.size(); ++i) {
46 wstm << ctfacet.widen(str[i]);
52 INLINE std::string
narrow(
const std::wstring& str) {
53 std::ostringstream stm;
54 const std::ctype< char >& ctfacet =
55 std::use_facet< std::ctype< char > >(stm.getloc());
57 for (std::size_t i = 0; i < str.size(); ++i) {
58 stm << ctfacet.narrow(str[i], 0);
64 #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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.