Skip to content

Commit c12957f

Browse files
committed
Fixed unicode handling - handling of special cases might still be problematic
1 parent ab202ae commit c12957f

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

JsonStreamingParser.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,9 @@ void JsonStreamingParser::processUnicodeCharacter(char c) {
332332

333333
if (unicodeBufferPos == 4) {
334334
int codepoint = getHexArrayAsDecimal(unicodeBuffer, unicodeBufferPos);
335-
if (codepoint >= 0xD800 && codepoint < 0xDC00) {
335+
endUnicodeCharacter(codepoint);
336+
return;
337+
/*if (codepoint >= 0xD800 && codepoint < 0xDC00) {
336338
unicodeHighSurrogate = codepoint;
337339
unicodeBufferPos = 0;
338340
state = STATE_UNICODE_SURROGATE;
@@ -348,9 +350,10 @@ void JsonStreamingParser::processUnicodeCharacter(char c) {
348350
// throw new ParsingError($this->_line_number,
349351
// $this->_char_number,
350352
// "Invalid low surrogate following Unicode high surrogate.");
353+
endUnicodeCharacter(codepoint);
351354
} else {
352355
endUnicodeCharacter(codepoint);
353-
}
356+
}*/
354357
}
355358
}
356359
boolean JsonStreamingParser::isHexCharacter(char c) {
@@ -390,6 +393,7 @@ void JsonStreamingParser::endUnicodeSurrogateInterstitial() {
390393
// "Expected '\\u' following a Unicode high surrogate. Got: " .
391394
// $unicode_escape);
392395
}
396+
unicodeBufferPos = 0;
393397
unicodeEscapeBufferPos = 0;
394398
state = STATE_UNICODE;
395399
}

JsonStreamingParser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ class JsonStreamingParser {
6565
char buffer[BUFFER_MAX_LENGTH];
6666
int bufferPos = 0;
6767

68-
char unicodeEscapeBuffer[128];
68+
char unicodeEscapeBuffer[10];
6969
int unicodeEscapeBufferPos = 0;
7070

71-
char unicodeBuffer[128];
71+
char unicodeBuffer[10];
7272
int unicodeBufferPos = 0;
7373

7474
int characterCounter = 0;

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"name": "Daniel Eichhorn",
1111
"url": "http://blog.squix.ch"
1212
},
13-
"version": "1.0.3",
13+
"version": "1.0.4",
1414
"frameworks": "arduino",
1515
"platforms": "*",
1616
"examples": [

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Json Streaming Parser
2-
version=1.0.3
2+
version=1.0.4
33
author=Daniel Eichhorn
44
maintainer=Daniel Eichhorn <[email protected]>
55
sentence=A very memory efficient library to parse (large) JSON objects on small devices

0 commit comments

Comments
 (0)