[Qt-interest] How to compress QString

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Thu Apr 16 14:27:36 CEST 2009


Iurii Gordiienko wrote on Thursday, April 16, 2009 1:48 PM:

> We can't convert UNICODE string to UTF-8 because data will be loss.

I don't quite understand: which data will be lost? UTF-8 is a perfect representation of ANY unicode character! 

Roughly said for ASCII characters UTF-8 uses just 1 byte, for all other characters it uses more than what UTF-16 representation would use (e.g. 3 or 4, instead of just 2 bytes per character) ("multibyte sequence").

I am not an Unicode expert, so some details above might be plain wrong; but you can convert from UTF-16 to UTF-8 back and forth, without data loss!

Also refer to http://doc.trolltech.com/4.5/qstring.html#details: "toUtf8() returns a UTF-8 encoded 8-bit string. UTF-8 is a superset of ASCII that supports the entire Unicode character set through multibyte sequences."


Cheers, Oliver
-- 
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22



More information about the Qt-interest-old mailing list