Mercurial > hg > easyhg
changeset 410:4f5414a7edb4
Handle escaped backslash (\\u) for cases where Unicode escape is not intended
author | Chris Cannam |
---|---|
date | Tue, 07 Jun 2011 10:59:28 +0100 |
parents | 69fb864a3972 |
children | d0ebd797c5a1 |
files | src/common.cpp |
diffstat | 1 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/common.cpp Mon Jun 06 21:33:25 2011 +0100 +++ b/src/common.cpp Tue Jun 07 10:59:28 2011 +0100 @@ -262,14 +262,24 @@ { QString d; for (int i = 0; i < s.length(); ++i) { + // backslash-u escaped with another backslash: replace with a + // single backslash and skip on + if (i+2 < s.length() && s[i] == '\\' && s[i+1] == '\\' && s[i+2] == 'u') { + d += "\\u"; + i += 2; + continue; + } + // unescaped backslash followed by u and at least four more + // chars: replace with Unicode character 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]; + continue; } + // default case: leave alone + d += s[i]; } return d; }