首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用IwGxFontDrawText显示cyrillic字体

使用IwGxFontDrawText显示cyrillic字体
EN

Stack Overflow用户
提问于 2014-09-04 08:10:12
回答 1查看 113关注 0票数 0

我试图使用IwGxFontDrawText函数在Marmalade项目中显示cyrillic的字符串。我添加了TimesNewRoman ttf文件,我的代码:

代码语言:javascript
复制
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;
}

当我显示拉丁文-所有的工作,但当我显示西里尔文字-我得到一个错误。

我怎样才能显示西里尔的文字?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-04 09:11:02

消息说您的字符串不是UTF-8编码的。由于您的字符串直接来自源代码,这意味着您的源代码不是UTF-8编码。要么使用UTF-8作为源代码编码(这是个不错的主意,因为它使您的源代码可移植),或者您应该转换字符串文字的编码。我更喜欢第一个。

许多编辑器和IDE使用特定于平台的编码。那不是Windows上的UTF-8。然而,大多数编辑器和IDE支持UTF-8编码.在编辑器的设置中搜索。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25660362

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档