Skip to content

Commit

Permalink
Fix lowercase unicode escaped sequence (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianfett authored Jun 24, 2020
1 parent 2aaa3eb commit 9d10426
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/PureSwiftJSONParsing/DocumentReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ public struct DocumentReader {
case 48...57:
return ascii - 48
case 65...70:
// uppercase letters
return ascii - 55
case 97...102:
// lowercase letters
return ascii - 87
default:
return nil
}
Expand Down
6 changes: 6 additions & 0 deletions Tests/JSONParsingTests/StringParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class StringParserTests: XCTestCase {
XCTAssertNoThrow(result = try JSONParser().parse(bytes: [UInt8](#""\u005A""#.utf8)))
XCTAssertEqual(result, .string("Z"))
}

func testSimpleLowercaseEscapedUnicode() {
var result: JSONValue?
XCTAssertNoThrow(result = try JSONParser().parse(bytes: [UInt8](#""\u003c""#.utf8)))
XCTAssertEqual(result, .string("<"))
}

func test12CharacterSequenceUnicode() {
// from: https://en.wikipedia.org/wiki/UTF-16#Examples
Expand Down

0 comments on commit 9d10426

Please sign in to comment.