27 #ifndef INCLUDED_WideToUTF8_h_GUID_A2C0AD0B_9DEB_4E84_5A3A_8517ED03AA32 
   28 #define INCLUDED_WideToUTF8_h_GUID_A2C0AD0B_9DEB_4E84_5A3A_8517ED03AA32 
   30 #ifndef OSVR_HAVE_CODECVT 
   35 #define WIN32_LEAN_AND_MEAN 
   38 #ifdef OSVR_HAVE_CODECVT 
   41 #else // !OSVR_HAVE_CODECVT 
   42 #include <boost/locale/encoding_utf.hpp> 
   43 #endif // OSVR_HAVE_CODECVT 
   46 #include <type_traits> 
   51     template <
typename T> 
inline std::string wideToUTF8String(T input) {
 
   52 #ifdef OSVR_HAVE_CODECVT 
   53         std::wstring_convert<std::codecvt_utf8<wchar_t> > strCvt;
 
   54         return strCvt.to_bytes(input);
 
   55 #else  // !OSVR_HAVE_CODECVT 
   56         return boost::locale::conv::utf_to_utf<char>(input);
 
   57 #endif // OSVR_HAVE_CODECVT 
   60     template <
typename T> 
inline std::wstring utf8ToWideString(T input) {
 
   61 #ifdef OSVR_HAVE_CODECVT 
   62         std::wstring_convert<std::codecvt_utf8<wchar_t> > strCvt;
 
   63         return strCvt.from_bytes(input);
 
   64 #else  // !OSVR_HAVE_CODECVT 
   65         return boost::locale::conv::utf_to_utf<wchar_t>(input);
 
   66 #endif // OSVR_HAVE_CODECVT 
   70     inline std::string tcharToUTF8String(TCHAR buf[]) {
 
   71         static_assert(std::is_same<TCHAR, wchar_t>::value,
 
   72                       "This code path relies on TCHAR being a wchar_t!");
 
   73         return wideToUTF8String(buf);
 
   76     inline std::string tcharToUTF8String(TCHAR buf[]) {
 
   77         static_assert(std::is_same<TCHAR, char>::value,
 
   78                       "This code path relies on TCHAR being a single byte!");
 
   79         return std::string(buf);
 
   88 #endif // INCLUDED_WideToUTF8_h_GUID_A2C0AD0B_9DEB_4E84_5A3A_8517ED03AA32