Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Matticus

Pages: [1]
1
System / Re: Unable to display Japanese characters
« on: June 11, 2012, 01:14:07 pm »
You can't define Unicode characters in a "regular" string literal (made of 8-bit chars), you need at least a wide string literal.
msg = L"こんにちはSMFL";
hdr = L"こんにちはSMFL";

That was the solution, thank you for your help!

And by the way, it is SFML.

Ah, sorry.  Slip of the index ._.

2
System / Unable to display Japanese characters
« on: June 11, 2012, 02:54:16 am »
Hello, I've been trying to get Japanese characters to render in SFML 2 RC to no avail.  I've used the font from this thread so that I know the font is compatible. Direct link for convenience.

The Japanese text comes up as question marks while English text displays normally.  Sample code is below, thank you for reading:

#include <SFML/Graphics.hpp>
#include <SFML/System/Utf.hpp>
#include <iostream>

int main()
{
        sf::Font font;
        sf::String msg, hdr;
        sf::Text text;

        if(!font.loadFromFile("test.ttf"))
        {
                text.setString("Load failed"); 
                hdr = "Warning!";
        }
        else
        {
                font.loadFromFile("test.ttf");
                //char jp[2] = { '\u70B9','\u83DC' }; //error even worse here
                //msg = jp;
                msg = "&#12371;&#12435;&#12395;&#12385;&#12399;SMFL"; //tested this first, Japanese characters come up as "??????SMFL"
                hdr = "&#12371;&#12435;&#12395;&#12385;&#12399;SMFL";
       
                //Set up for potential conversion from different utf types
                /*sf::Utf<8>::toUtf32(msg.begin(), msg.end(), msg.begin());
                sf::Utf<8>::toUtf32(hdr.begin(), hdr.end(), hdr.begin());*/


                text.setFont(font);
                text.setString(msg);
        }

        sf::RenderWindow window(sf::VideoMode(300, 200), hdr);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(text);
        window.display();
    }

    return 0;
}

Pages: [1]
anything