- qp::StringW Global::AnsiToUnicode(const char* buf)
- {
- int len = ::MultiByteToWideChar(CP_ACP, 0, buf, -1, NULL, 0);
- if (len == 0) return L"";
-
- std::vector<wchar_t> unicode(len);
- ::MultiByteToWideChar(CP_ACP, 0, buf, -1, &unicode[0], len);
-
- return &unicode[0];
- }
-
- qp::StringA Global::UnicodeToAnsi(const wchar_t* buf)
- {
- int len = ::WideCharToMultiByte(CP_ACP, 0, buf, -1, NULL, 0, NULL, NULL);
- if (len == 0) return "";
-
- std::vector<char> utf8(len);
- ::WideCharToMultiByte(CP_ACP, 0, buf, -1, &utf8[0], len, NULL, NULL);
-
- return &utf8[0];
- }
-
- qp::StringW Global::Utf8ToUnicode(const char* buf)
- {
- int len = ::MultiByteToWideChar(CP_UTF8, 0, buf, -1, NULL, 0);
- if (len == 0) return L"";
-
- std::vector<wchar_t> unicode(len);
- ::MultiByteToWideChar(CP_UTF8, 0, buf, -1, &unicode[0], len);
-
- return &unicode[0];
- }
-
- qp::StringA Global::UnicodeToUtf8(const wchar_t* buf)
- {
- int len = ::WideCharToMultiByte(CP_UTF8, 0, buf, -1, NULL, 0, NULL, NULL);
- if (len == 0) return "";
-
- std::vector<char> utf8(len);
- ::WideCharToMultiByte(CP_UTF8, 0, buf, -1, &utf8[0], len, NULL, NULL);
-
- return &utf8[0];
- }
posted @
2013-04-19 13:43
stma
阅读(
423)
评论()
收藏
举报