#include <QtGui>
int main(int argc, char **argv)
{
// UTF-8
const char s[] = {
0x78, // Lower case X
0xE2, 0x81, 0xB0, // superscript zero
0xC2, 0xB9, // superscript one
0xC2, 0xB2, // superscript two
0xE2, 0x82, 0x83, // subscript three
0xE2, 0x82, 0x84, // subscript four
0x00 // NUL terminator
};
// UTF-16, BOM then same characters as above
const ushort s16[] = {
0xFEFF, // byte order mark
0x0078,
0x2070,
0x00B9,
0x00B2,
0x2083,
0x2084,
0x0
};
// str == str16 is true
l.setFont(font);
l.show();
return app.exec();
}
#include <QtGui>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
// UTF-8
const char s[] = {
0x78, // Lower case X
0xE2, 0x81, 0xB0, // superscript zero
0xC2, 0xB9, // superscript one
0xC2, 0xB2, // superscript two
0xE2, 0x82, 0x83, // subscript three
0xE2, 0x82, 0x84, // subscript four
0x00 // NUL terminator
};
QString str = QString::fromUtf8(s);
// UTF-16, BOM then same characters as above
const ushort s16[] = {
0xFEFF, // byte order mark
0x0078,
0x2070,
0x00B9,
0x00B2,
0x2083,
0x2084,
0x0
};
QString str16 = QString::fromUtf16(s16);
// str == str16 is true
QFont font("Arial", 36);
QLabel l(str16);
l.setFont(font);
l.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks