diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2016-04-05 15:28:16 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2016-04-05 13:36:45 +0000 |
commit | d29e5339641e6f40b0089d6d1d71532e7be3a76f (patch) | |
tree | a4407c3eb8da0428b88c954f206567053cfe6f00 /tools/qscxmlc/scxmlcppdumper.cpp | |
parent | fb492a968b7526fb3c9db5af9c12f15afcde3639 (diff) |
Use C escaping instead of hex encoding for generated metadata
Hex-encoding characters above 0xff is hard to do in a cross-platform
way. However, using C++11, we should be able to get portable wide
character literals.
Change-Id: I9b4faa7f443c00b43c8f15e5d1411b2d82609623
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Diffstat (limited to 'tools/qscxmlc/scxmlcppdumper.cpp')
-rw-r--r-- | tools/qscxmlc/scxmlcppdumper.cpp | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/tools/qscxmlc/scxmlcppdumper.cpp b/tools/qscxmlc/scxmlcppdumper.cpp index 1e3e0b7..f981486 100644 --- a/tools/qscxmlc/scxmlcppdumper.cpp +++ b/tools/qscxmlc/scxmlcppdumper.cpp @@ -179,20 +179,6 @@ QString cEscape(const QString &str) return str; } -static QString toHex(const QString &str) -{ - QString res; - for (int i = 0, ei = str.length(); i != ei; ++i) { - int ch = str.at(i).unicode(); - if (ch < 256) { - res += QStringLiteral("\\x%1").arg(ch, 2, 16, QLatin1Char('0')); - } else { - res += QStringLiteral("\\x%1").arg(ch, 4, 16, QLatin1Char('0')); - } - } - return res; -} - static const char *headerStart = "#include <QScxmlStateMachine>\n" "#include <QString>\n" @@ -1039,9 +1025,9 @@ private: t << QStringLiteral("QT_UNICODE_LITERAL_II(\"\")"); } else { for (int i = 0, ei = strings.size(); i < ei; ++i) { - QString s = strings.at(i); - QString comment = cEscape(s); - t << QStringLiteral("QT_UNICODE_LITERAL_II(\"%1\") // %3: %2").arg(toHex(s) + QStringLiteral("\\x00"), comment, QString::number(i)); + QString s = cEscape(strings.at(i)); + t << QStringLiteral("QT_UNICODE_LITERAL_II(\"%1\") // %3: %2") + .arg(s + QStringLiteral("\\x00"), s, QString::number(i)); } } t << QStringLiteral("};") << QStringLiteral(""); |