From ac2e202af40ac00a887ac23e452a46f6df87b077 Mon Sep 17 00:00:00 2001 From: Damien Date: Fri, 13 Jan 2012 16:30:25 +0100 Subject: [PATCH] Correct encoding in json parser Fixes #408. modified: src/JsonRideFile.y --- src/JsonRideFile.y | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/JsonRideFile.y b/src/JsonRideFile.y index 9040fb165..270d11d80 100644 --- a/src/JsonRideFile.y +++ b/src/JsonRideFile.y @@ -74,15 +74,18 @@ static QString protect(const QString string) s.replace("\b", "\\b"); // backspace s.replace("\f", "\\f"); // formfeed s.replace("/", "\\/"); // solidus + return s; } // Un-Escape special characters (JSON compliance) static QString unprotect(const QString string) { + QString string2 = QString::fromLocal8Bit(string.toAscii().data()); + // this is a lexer string so it will be enclosed // in quotes. Lets strip those first - QString s = string.mid(1,string.length()-2); + QString s = string2.mid(1,string2.length()-2); // now un-escape the control characters s.replace("\\t", "\t"); // tab @@ -93,6 +96,7 @@ static QString unprotect(const QString string) s.replace("\\/", "/"); // solidus s.replace("\\\"", "\""); // quote s.replace("\\\\", "\\"); // backslash + return s; }