comparison 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
comparison
equal deleted inserted replaced
407:b45e6cd9f1d4 408:005633eed862
255 .replace("\"", """) 255 .replace("\"", """)
256 .replace("'", "'"); 256 .replace("'", "'");
257 257
258 return s; 258 return s;
259 } 259 }
260
261 QString uniDecode(QString s)
262 {
263 QString d;
264 for (int i = 0; i < s.length(); ++i) {
265 if (i+5 < s.length() && s[i] == '\\' && s[i+1] == 'u') {
266 QString uni = s.mid(i+2, 4);
267 QByteArray ba = QByteArray::fromHex(uni.toAscii());
268 d += QChar(ba[1], ba[0]);
269 i += 5;
270 } else {
271 d += s[i];
272 }
273 }
274 return d;
275 }