Output funky UTF-8 to console



  • I have a console program that uses various QT classes. It needs to be translatable into Japanese.

    I am pretty sure my terminal is showing such glyphs correctly, as I have a directory named 我能吞下玻璃而 that quite happily appears in my Gnome terminal.

    I thought I'd start by making one of the QStrings inside the console contain some of these characters, and just see if I can get them all the way out to the console. I cannot :(

    The QString is question is created like this:
    @const QString Message_Location(QObject::tr(" 形声文字 of : "));@

    It is then passed to a QTextStream& object, m_output;
    @ m_output << Message_Location << endl;@

    m_output seems to be a reference to a QTextStream object created like this in an initialiser list:
    @m_stdOutput(stdout, QIODevice::WriteOnly)@

    The output I actually get in the console is:
    @形声文字 of@
    although on my console some of that is those little rectangles with numbers in that one gets when something's gone wrong with the character handling.

    Right before this line executes:
    @ m_output << Message_Location << endl;@
    I can use the debugger and see that Mesasge_Location is a QString containing the value @形声æ\226\207å­\227 of@

    I really don't know where to look first for something like this. Can anyone help?



  • Hi, if you are running your console program on Windows, you will find displaying UTF-8 difficult in some programs , like the CMD console and Notepad. Due to age they do not understand UTF-8.
    Suggest you try another operating system :-)



  • I'm using Gnome terminal in Ubuntu.


  • Moderators

    Hi,

    You need 3 things:


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.