[Qt-interest] QByteArray can't not show japanese language chars?

Thiago Macieira thiago.macieira at trolltech.com
Tue Feb 17 11:09:00 CET 2009


Em Terça-feira 17 Fevereiro 2009, às 09:03:00, ri at eeda.denso.co.jp escreveu:
> hi
>
> I build a  QByteArray list like this:
>  >> QList<QByteArray> myList;
>  >> myList.append( QFile->readLine() )
>
> there're some japanese language characters contained in some lines.
>
> I read all the lines in the file, do my job with myList, and want to save
> it back to the file.
>
>   QTextStream out(&file);
>   out << myList.at(xxx) << "\n";
>
> but found that all the japanese language characters are transformed  to "?"
>
> How do I solve this problem?

QByteArray is, like the name says, an array of bytes. It doesn't specify 
encoding, so it's technically just binary data.

If you want the concept of characters (Japanese or otherwise), you need to 
convert it to QString first. In that case, QTextStream will do the right thing 
when outputting.

-- 
Thiago Macieira - thiago.macieira (AT) nokia.com
  Senior Product Manager - Nokia, Qt Software
     Sandakerveien 116, NO-0402 Oslo, Norway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090217/0d11c1e2/attachment.bin 


More information about the Qt-interest-old mailing list