[Qt-interest] QString and UNICODE: size determination

Girish Ramakrishnan girish at forwardbias.in
Thu Jul 9 16:02:41 CEST 2009


Constantin Makshin wrote:
> QString *always* stores Unicode characters, so the amount of memory used
> by QString's contents is "str.size() * 2" or, what should be even better
> (forward compatibility, etc.), "str.size() * sizeof(QChar)".

sizeof(QChar) is the size of QChar object, which is not necessarily 2
(but it should be on most compilers). I would suggest str.size() * 2
instead.

Girish



More information about the Qt-interest-old mailing list