Originally Posted by
reddish
This is the one case I yearn for Java (where you can put \u escape codes in a string) although I realize Qt is not to blame for C++ shortcomings in this area.
Well, it is not a C++ shortcoming. C++ allows the following declaration:
const wchar_t somestring = L"The Euro symbol is: \x20ac.";
const wchar_t somestring = L"The Euro symbol is: \x20ac.";
To copy to clipboard, switch view to plain text mode
A bit cumbersome is that, to have a Qt QString from it, you have to use the QString::fromWCharArray() function:
[...
]->setText
(QString::fromWCharArray(somestring
) );
[...]->setText(QString::fromWCharArray(somestring) );
To copy to clipboard, switch view to plain text mode
which of course cannot be put in the declaration:
const QString somestring
= QString::fromWCharArray(L
"The Euro symbol is: \x20ac.");
// not legal!
const QString somestring = QString::fromWCharArray(L"The Euro symbol is: \x20ac."); // not legal!
To copy to clipboard, switch view to plain text mode
A QString constructor accepting a wchar_t[] as parameter could be useful...
M.
P.S.: if the characters following the \x escape sequence could be interpreted as hex digits, the wchar_t string must be split:
const wchar_t somestring = L"The Euro symbol is: \x20ac" "ABCD";
const wchar_t somestring = L"The Euro symbol is: \x20ac" "ABCD";
To copy to clipboard, switch view to plain text mode
Bookmarks