关于cocos2dx 在wp8 中 如何显示中文
来源:互联网 发布:mac平台 编辑:程序博客网 时间:2024/05/22 01:29
效果如下:
在项目中 因为遇到 非英文字符不显示问题,于是各种查资料,网上说的方法大多是转码,而且是在 win32平台下实现的,关于winphone 8上显示中文的资料很少,这里我耗费了很多时间,只是因为粗心大意没有看到 labeltest里边的一句话注释::
注释中说 需要自己下载字体然后 显示,但是下载后仍然显示 ,然后就想到了转码,这里之所以想到转码是,我在win32下面已经经过转码显示出来了中文! 实验之后成功显示! 做个小记:转码的方法有很多种,這里提供两种可以参考!
char* G2U(const char* gb2312)
{
int len = MultiByteToWideChar(CP_ACP, 0, gb2312, -1, NULL, 0);
wchar_t* wstr = new wchar_t[len + 1];
memset(wstr, 0, len + 1);
MultiByteToWideChar(CP_ACP, 0, gb2312, -1, wstr, len);
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
char* str = new char[len + 1];
memset(str, 0, len + 1);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
if (wstr) delete[] wstr;
return str;
}
inline string GB2312ToUTF8(const char* pStrGB2312) {
string out = "";
// to wide char
int nStrLen = MultiByteToWideChar(936, 0, pStrGB2312, -1, NULL, 0);
wchar_t* pWStr = new wchar_t[nStrLen + 1];
memset(pWStr, 0, nStrLen + 1);
MultiByteToWideChar(936, 0, pStrGB2312, -1, pWStr, nStrLen);
// to utf-8
nStrLen = WideCharToMultiByte(CP_UTF8, 0, pWStr, -1, NULL, 0, NULL, NULL);
char* pStr = new char[nStrLen + 1];
memset(pStr, 0, nStrLen + 1);
WideCharToMultiByte(CP_UTF8, 0, pWStr, -1, pStr, nStrLen, NULL, NULL);
if (pWStr) {
delete[] pWStr;
}
if (pStr) {
out = pStr;
delete[] pStr;
}
return out;
}
- 关于cocos2dx 在wp8 中 如何显示中文
- cocos2dx在windows下如何显示中文
- 利用cocos2dx 3.2开发消灭星星(六)如何在cocos2dx中显示中文
- 在cocos2dx 中如何使用中文
- Cocos2dx杂记:如何显示中文
- cocos2dx 3.1中显示中文
- 如何vs在cocos2dx项目中打印中文
- 如何在linux中显示中文
- 如何在qt中显示中文
- 如何在xml中显示中文
- 如何在QT中显示中文字符
- Cocos2dx杂记:如何显示中文(2)
- 关于mysql中如何显示中文及在myeclipse上关联mysql等的一些小结
- Cocos2dx-Wp8
- cocos2d-x wp8 中文显示问题
- [cocos2dx]在cocos2dx中使用iconv库解决中文乱码
- 在WP8 中使用SQLite
- 在wp8中使用opencv
- poj 3072(最短路)
- poj 3255(次短路)
- poj 3311(floyd+状态压缩)
- poj 3328(多起点多终点的最短路)
- poj 3613(经过N条边的最短路)
- 关于cocos2dx 在wp8 中 如何显示中文
- poj 3615(floyd变形)
- hdu 4462(状态压缩)
- hdu 4628(状态压缩)
- poj 3635(bfs+优先队列)
- Linux 文件系统目录结构
- poj 3662(经典最短路)
- poj 3621(最优比率环)
- hdu 1531(差分约束)