[Qt-interest] how to convert Unicode to printable string in QT stream

Meir Yanovich meiry242 at gmail.com
Sun May 2 10:16:39 CEST 2010


Thanks for the reply but isn't there more straight way to do that
what is this encoding im getting any way ?

On Sun, May 2, 2010 at 10:49 AM, Diego Iastrubni <diegoiast at gmail.com>wrote:

> Hi Meir,
>
> Not pretty, but works (I assume someone else will give a better solution
> soon):
>
> #include <QtCore>
> #include <QApplication>
> #include <QMessageBox>
> #include <QString>
> #include <QChar>
> #include <QStringList>
>
> int main(int argc, char *argv[])
> {
>     QApplication app(argc,argv);
>     QString     s =
> "\\u05ea\\u05e7\\u05dc\\u05d9\\u05d8\\u05e9\\u05e1\\u05d9\\u05de\\u05dc\\u05e9\\u05d9\\u05e0\\u05d5\\u05d9\\u05d1\\u05e1\\u05d2\\u05e0\\u05d5\\u05df\\u05dc\\u05d3\\u05e2\\u05ea\\u05d9\\u05d0\\u05dd\\u05d0\\u05e0\\u05d9\\u05d6\\u05d5\\u05db\\u05e8\\u05e0\\u05db\\u05d5\\u05df";
>     QStringList l = s.split("\\u");
>     QString     output;
>     foreach(QString s1, l){
>         bool b;
>         int i = s1.toInt(&b,16);
>         output += QChar(i);
>         qDebug( "number is '%s' -> '%d', %i", qPrintable(s1), i, b );
>     }
>
>     QMessageBox::information ( 0, "Output", output );
>     qDebug("length is: %d\n%s", output.length(), qPrintable(output) );
> }
>
> On Sun, May 2, 2010 at 10:10 AM, Meir Yanovich <meiry242 at gmail.com> wrote:
>
>> I'm writing a stream to a file and stdout, but I'm getting some kind of
>> encoding like this:
>>
>> \u05ea\u05e7\u05dc\u05d9\u05d8 \u05e9\u05e1\u05d9\u05de\u05dc
>> \u05e9\u05d9\u05e0\u05d5\u05d9 \u05d1\u05e1\u05d2\u05e0\u05d5\u05df
>> \u05dc\u05d3\u05e2\u05ea\u05d9 \u05d0\u05dd \u05d0\u05e0\u05d9
>> \u05d6\u05d5\u05db\u05e8 \u05e0\u05db\u05d5\u05df
>>
>> How can I convert this to a printable string?
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100502/148385ec/attachment.html 


More information about the Qt-interest-old mailing list