[Qt-interest] Does Qt support Unicode 5.1?
Constantin Makshin
dinosaur-rus at users.sourceforge.net
Thu Mar 5 23:57:43 CET 2009
Internally, QChar is a single 16-bit integer, so one QChar can represent
only one 16-bit (UCS-2) character. Obviously, to use combined UTF-16
characters, you need 2 QChar-s.
And, as I said, surrogate handling functions provided by Qt are likely to
be broken, so don't rely on them.
On Fri, 06 Mar 2009 01:33:24 +0300, Shaun Cummins <cumminss at gmail.com>
wrote:
> Thanks! That makes perfect sense. So when encoding with UTF-16 a 20 bit
> value (a character outside of the BMP) is split into two 10 bit values
> and placed into a reserved section that only takes about 3% of the
> entire range of the BMP.
>
> The only thing that doesn't make sense to me is why Qt doesn't do this
> automatically. It seems like the code in QChar should be able to handle
> this without needing to explicitly do the work myself (by simply
> checking that a value is not within the BMP and doing the necessary
> adjustments you
> do in your code--especially since they already have utility functions to
> take the low and high surrogates of a ucs4 value). I was confused
> because there are constructors for QChar that take integers, another
> that takes unsigned
> integers and other that take shorts or unsigned shorts. Since they made
> an explicit constructor for integers I presumed that they could handle
> values greater than 0xFFFF correctly.
--
Constantin "Dinosaur" Makshin
More information about the Qt-interest-old
mailing list