|
|
发表于 2009-5-26 14:35:00
|
显示全部楼层
Re: 老题重谈,怎样把一个CEGUI::String转化成std::string
- std::string& decode(const CEGUI::String& str)
- {
- char sdes[2048];
- static std::string result;
- int len = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0);
- wchar_t* wcstr = new wchar_t[len];
- MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, wcstr, len);
- int wlen = WideCharToMultiByte(CP_ACP, 0, wcstr, -1, NULL, 0, NULL, NULL);
- char* nstr = new char[wlen];
- WideCharToMultiByte(CP_ACP, 0, wcstr, -1, nstr, wlen, NULL, NULL);
- strcpy(sdes, nstr);
- delete[] wcstr;
- delete[] nstr;
- result = sdes;
- return result;
- }
复制代码 |
|