0

I'm trying to show cyrillic's string in my Marmalade project, using IwGxFontDrawText function. I've added TimesNewRoman ttf file, and my code:

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;
}

When I show latin text - all works, but when I show cyrillic text - I getting an error enter image description here

How can I show cyrillic text?

Csq
  • 5,775
  • 6
  • 26
  • 39
daleijn
  • 718
  • 13
  • 22
  • As the message asks: Is your source code (and therefore your string literal) [UTF-8](http://en.wikipedia.org/wiki/UTF-8) encoded? Many editors use native encoding and that is not UTF-8 on Windows. – Csq Sep 04 '14 at 08:26
  • @Csq, how can I convert my string literal to UTF-8? – daleijn Sep 04 '14 at 08:30
  • 1
    Which editor do you use? Search for UTF-8 encoding in its settings. Most editors are capable of UTF-8. For example, Notepad++ can save (and even convert) UTF-8 files (see its Encoding menu). – Csq Sep 04 '14 at 08:33
  • I'm using VS, I've changed encoding settings, and all works, thank you very much! – daleijn Sep 04 '14 at 08:51
  • Ok, I've made that an answer then. – Csq Sep 04 '14 at 09:11

1 Answers1

1

The message says that your string is not UTF-8 encoded. As your string comes directly form the source code, that means that your source code is not UTF-8 encoded. Either you use UTF-8 as your source code encoding (it is not a bad idea anyway, since it make your source code portable) or you should convert the encoding of the string literal. I would prefer the first.

Many editors and IDEs use platform-specific encoding. That is not UTF-8 on Windows. However, most editors and IDEs support UTF-8 encoding. Search for in the settings of your editor.

Csq
  • 5,775
  • 6
  • 26
  • 39