diff src/common.cpp @ 408:005633eed862

Add uniDecode, and use it when parsing logs so as to decode "\uABCD" substrings. Also force Hg encoding to utf-8.
author Chris Cannam
date Mon, 06 Jun 2011 21:20:11 +0100
parents b9c153e00e84
children 4f5414a7edb4
line wrap: on
line diff
--- a/src/common.cpp	Thu May 26 15:52:11 2011 +0100
+++ b/src/common.cpp	Mon Jun 06 21:20:11 2011 +0100
@@ -257,3 +257,19 @@
 
     return s;
 }
+
+QString uniDecode(QString s)
+{
+    QString d;
+    for (int i = 0; i < s.length(); ++i) {
+        if (i+5 < s.length() && s[i] == '\\' && s[i+1] == 'u') {
+            QString uni = s.mid(i+2, 4);
+            QByteArray ba = QByteArray::fromHex(uni.toAscii());
+            d += QChar(ba[1], ba[0]);
+            i += 5;
+        } else {
+            d += s[i];
+        }
+    }
+    return d;
+}