CEGUI字符串转换问题
CEGUI支持中文字体是不用说了,需要中文显示时所需的配置可以参见网络上其他相关文章,这里说得是字符串转换问题,应为CEGUI有自己的字符串类(CEGUI::String),显示时需要把char*转换为CEGUI::String,下面这个小算法可以实现这个功能,具体就不多说了,各位复制粘贴即可,^_^。
1CEGUI::String& encode(const char * c)
2{
3 static CEGUI::String str;
4 WCHAR e;
5 str.clear();
6 int i = 0;
7 while(c[i])
8 {
9 if(unsigned char(c[i])>=161)
10 {
11 MultiByteToWideChar(0,0,c+i,2,&e,1);
12
13 str.append(1,e);
14 i+=2;
15 }
16 else
17 {
18 str.append(1,c[i]);
19 i++;
20 }
21 }
22
23 return str;
24}
2{
3 static CEGUI::String str;
4 WCHAR e;
5 str.clear();
6 int i = 0;
7 while(c[i])
8 {
9 if(unsigned char(c[i])>=161)
10 {
11 MultiByteToWideChar(0,0,c+i,2,&e,1);
12
13 str.append(1,e);
14 i+=2;
15 }
16 else
17 {
18 str.append(1,c[i]);
19 i++;
20 }
21 }
22
23 return str;
24}
posted on 2007-12-12 20:20 gogoplayer 阅读(1538) 评论(5) 编辑 收藏 举报