forked from qt-creator/qt-creator
Marcos: Make Utils.asciify(...) avialable to MarcoExpander
The Util.asciify(...) method takes a string and returns an ASCII only string for the input. All ASCII characters are kept as is, anything non-ASCII is replaced by 'u' followed by the hex encoded unicode value of the character. Change-Id: I90b0adeb809bc2f6eb4374ce48851396861d4673 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -142,5 +142,17 @@ QString UtilsJsExtension::mktemp(const QString &pattern) const
|
||||
return file.fileName();
|
||||
}
|
||||
|
||||
QString UtilsJsExtension::asciify(const QString &input) const
|
||||
{
|
||||
QString result;
|
||||
for (const QChar c : input) {
|
||||
if (c.isPrint() && c.unicode() < 128)
|
||||
result.append(c);
|
||||
else
|
||||
result.append(QString::fromLatin1("u%1").arg(c.unicode(), 4, 16, QChar('0')));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
Reference in New Issue
Block a user