The pound symbol is Unicode code point U+00A3, 163 in decimal. Using QString(163) causes an implicit conversion to a Unicode QChar using the short/int constructor so that the compiler can use it in the QString constructor.
The two characters the OP saw are the result of treating the two bytes that U+00A3 occupies in UTF8 (\xC2 \xA3) as two separate characters in ISO8859-1 (Latin1) or a similar 8-bit encoding. Assuming the original poster was using an editor saving in UTF8 encoding this would have worked:
qDebug
() <<
QString::fromUtf8("text £%1 text").
arg(1000);
// literally typing the pound symbol into the string// output is
"text £1000 text"
qDebug() << QString::fromUtf8("text £%1 text").arg(1000); // literally typing the pound symbol into the string
// output is
"text £1000 text"
To copy to clipboard, switch view to plain text mode
and been easier to understand than QString(163).
156 is the position of the £ symbol in "Code Page 437" used by IBM in the original PC to extend the 7-bit ASCII code. AFAICT Qt has no way to convert from this encoding.
Bookmarks