Changeset 281 for cpp/common/Convert.h


Ignore:
Timestamp:
12/27/14 01:01:43 (9 years ago)
Author:
Maciej Komosinski
Message:

Support for wide char (unicode) names of files and directories under Windows, internally encoded as char* utf-8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/Convert.h

    r247 r281  
    7272        }
    7373
    74         static string wstrTOutf8(const wchar_t *s)
    75         {
    76                 if (s == NULL) return "";
    77                 string res;
    78                 wchar_t *wcp = (wchar_t*)s;
    79                 while (*wcp != 0)
    80                 {
    81                         int c = *wcp;
    82                         if (c < 0x80) res += c;
    83                         else if (c < 0x800) { res += 192 + c / 64; res += 128 + c % 64; }
    84                         else if (c - 0xd800u < 0x800) res += "<ERR-CHAR>";
    85                         else if (c < 0x10000) { res += 224 + c / 4096; res += 128 + c / 64 % 64; res += 128 + c % 64; }
    86                         else if (c < 0x110000) { res += 240 + c / 262144; res += 128 + c / 4096 % 64; res += 128 + c / 64 % 64; res += 128 + c % 64; }
    87                         else res += "<ERR-CHAR>";
    88                         wcp++;
    89                 }
    90                 return res;
    91         }
    92         //#endif
     74        static string wstrToUtf8(const wchar_t *str);
     75#ifdef _WIN32
     76        static wstring utf8ToUtf16(const char *str);
     77#endif
    9378};
    9479
Note: See TracChangeset for help on using the changeset viewer.