Qt-interest Archive, July 2007
Regarding a problem with getting the text in Japanese for QLineEdit
Message 1 in thread
Hi All,
I have a small problem here about getting the text in Japanese for QLineEdit with the help of text() function.
In the below code , I am setting the text for QLineEdit in japanese (line number:3) and in the next line, I am trying to retrieve the Japanese text in a QString (line number :4 ) but it is showing some junk characters like "????" while printing the label (line number: 5 ) .so how to get the text in Japanese?
...
1. QLineEdit lineEdit;
2 .QString label;
3. lineEdit.setText(QApplication::translate(" ","Japanese text",0,QApplication::UnicodeUTF8)); //setting the text for lineEdit in Japanese which is working fine
4. label = lineEdit.text(); //getting the text of lineEdit in Japanese which is not working
5. qDebug("print label %s",label.toLatin1().data()); //printing junk characters like ?????
..
Regards
Naveen
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
Message 2 in thread
On Tuesday 10 July 2007 08:53:46 naveen.kmrvm@xxxxxxxxx wrote:
> Hi All,
>
> I have a small problem here about getting the text in Japanese for
> QLineEdit with the help of text() function.
>
> In the below code , I am setting the text for QLineEdit in japanese (line
> number:3) and in the next line, I am trying to retrieve the Japanese text
> in a QString (line number :4 ) but it is showing some junk characters like
> "????" while printing the label (line number: 5 ) .so how to get the text
> in Japanese?
>
> 5. qDebug("print label %s",label.toLatin1().data()); //printing junk
> characters like ?????
Latin-1 only encodes characters found in western European languages. Japanese
cannot be represented in this encoding. You probably want to use
QString::toLocal8Bit() (or QString::toUtf8()) instead.
--
[ signature omitted ]
Message 3 in thread
Hi!
> 5. qDebug("print label %s",label.toLatin1().data()); //printing junk
> characters like ?????
Japanese characters are not a subset of Latin1 characters I guess..
therefore it is defined behaviour....
Greetings
Niklas
--
[ signature omitted ]