Skip to content

Commit

Permalink
Fixed unicode handling - handling of special cases might still be pro…
Browse files Browse the repository at this point in the history
…blematic
  • Loading branch information
squix78 committed Jun 5, 2016
1 parent ab202ae commit c12957f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions JsonStreamingParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ void JsonStreamingParser::processUnicodeCharacter(char c) {

if (unicodeBufferPos == 4) {
int codepoint = getHexArrayAsDecimal(unicodeBuffer, unicodeBufferPos);
if (codepoint >= 0xD800 && codepoint < 0xDC00) {
endUnicodeCharacter(codepoint);
return;
/*if (codepoint >= 0xD800 && codepoint < 0xDC00) {
unicodeHighSurrogate = codepoint;
unicodeBufferPos = 0;
state = STATE_UNICODE_SURROGATE;
Expand All @@ -348,9 +350,10 @@ void JsonStreamingParser::processUnicodeCharacter(char c) {
// throw new ParsingError($this->_line_number,
// $this->_char_number,
// "Invalid low surrogate following Unicode high surrogate.");
endUnicodeCharacter(codepoint);
} else {
endUnicodeCharacter(codepoint);
}
}*/
}
}
boolean JsonStreamingParser::isHexCharacter(char c) {
Expand Down Expand Up @@ -390,6 +393,7 @@ void JsonStreamingParser::endUnicodeSurrogateInterstitial() {
// "Expected '\\u' following a Unicode high surrogate. Got: " .
// $unicode_escape);
}
unicodeBufferPos = 0;
unicodeEscapeBufferPos = 0;
state = STATE_UNICODE;
}
Expand Down
4 changes: 2 additions & 2 deletions JsonStreamingParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ class JsonStreamingParser {
char buffer[BUFFER_MAX_LENGTH];
int bufferPos = 0;

char unicodeEscapeBuffer[128];
char unicodeEscapeBuffer[10];
int unicodeEscapeBufferPos = 0;

char unicodeBuffer[128];
char unicodeBuffer[10];
int unicodeBufferPos = 0;

int characterCounter = 0;
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "Daniel Eichhorn",
"url": "http://blog.squix.ch"
},
"version": "1.0.3",
"version": "1.0.4",
"frameworks": "arduino",
"platforms": "*",
"examples": [
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Json Streaming Parser
version=1.0.3
version=1.0.4
author=Daniel Eichhorn
maintainer=Daniel Eichhorn <[email protected]>
sentence=A very memory efficient library to parse (large) JSON objects on small devices
Expand Down

0 comments on commit c12957f

Please sign in to comment.