我试图使用IwGxFontDrawText函数在Marmalade项目中显示cyrillic的字符串。我添加了TimesNewRoman ttf文件,我的代码:
int main()
{
// Initialise Iw2D
Iw2DInit();
// Create the font that is used to display the score
CIwGxFont *Font = IwGxFontCreateTTFont("TNR_B.ttf", 14);
IwGxLightingOn();
IwGxFontSetFont(Font);
IwGxFontSetRect(CIwRect((int16)10, (int16)10, (int16)IwGxGetScreenWidth(), (int16)IwGxGetScreenHeight()));
int scores = 0;
while (!s3eDeviceCheckQuitRequest())
{
// Clear background to blue
Iw2DSurfaceClear(0xff8080);
IwGxFontDrawText("Привет: ");
// Convert the score number to text
char str[32];
snprintf(str, 32, " %d", scores);
IwGxFontDrawText(str);
scores++;
// Flip the surface buffer to screen
Iw2DSurfaceShow();
s3eDeviceYield(0); // Yield to OS
}
Iw2DTerminate();
return 0;
}当我显示拉丁文-所有的工作,但当我显示西里尔文字-我得到一个错误。

我怎样才能显示西里尔的文字?
发布于 2014-09-04 09:11:02
消息说您的字符串不是UTF-8编码的。由于您的字符串直接来自源代码,这意味着您的源代码不是UTF-8编码。要么使用UTF-8作为源代码编码(这是个不错的主意,因为它使您的源代码可移植),或者您应该转换字符串文字的编码。我更喜欢第一个。
许多编辑器和IDE使用特定于平台的编码。那不是Windows上的UTF-8。然而,大多数编辑器和IDE支持UTF-8编码.在编辑器的设置中搜索。
https://stackoverflow.com/questions/25660362
复制相似问题