Skip to content

Commit 3a21162

Browse files
committed
1 parent 79838aa commit 3a21162

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

JSON/src/Parser.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "Poco/JSON/JSONException.h"
3939
#include "Poco/Ascii.h"
4040
#include "Poco/Token.h"
41+
#include "Poco/UnicodeConverter.h"
4142
#undef min
4243
#undef max
4344
#include <limits>
@@ -140,28 +141,28 @@ class StringToken: public Token
140141
switch(c)
141142
{
142143
case '"' :
143-
c = '"';
144+
_value += '"';
144145
break;
145146
case '\\' :
146-
c = '\\';
147+
_value += '\\';
147148
break;
148149
case '/' :
149-
c = '/';
150+
_value += '/';
150151
break;
151152
case 'b' :
152-
c = '\b';
153+
_value += '\b';
153154
break;
154155
case 'f' :
155-
c = '\f';
156+
_value += '\f';
156157
break;
157158
case 'n' :
158-
c = '\n';
159+
_value += '\n';
159160
break;
160161
case 'r' :
161-
c = '\r';
162+
_value += '\r';
162163
break;
163164
case 't' :
164-
c = '\t';
165+
_value += '\t';
165166
break;
166167
case 'u' : // Unicode
167168
{
@@ -196,16 +197,21 @@ class StringToken: public Token
196197
{
197198
throw JSONException("Invalid unicode");
198199
}
199-
c = unicode;
200+
//unicode to utf8
201+
std::string utf8;
202+
UnicodeConverter::toUTF8((const UTF32Char*)&unicode,1,utf8);
203+
_value += utf8;
204+
200205
break;
201206
}
202207
default:
203208
{
204209
throw JSONException(format("Invalid escape '%c' character used", (char) c));
205210
}
206211
}
212+
}else{
213+
_value += c;
207214
}
208-
_value += c;
209215
c = istr.get();
210216
}
211217

0 commit comments

Comments
 (0)