diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-16 19:06:46 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-16 21:24:15 -0700 |
commit | 2b7fff828e29b63ae08a871b4b1e74784fab29e5 (patch) | |
tree | d95b3a00d4703c4c5eb41dce1529e4d675293ce5 /reencode.go | |
parent | 1e2d058c78969118b099940afdb100a3b93325cc (diff) |
Clean up the hex handling
Diffstat (limited to 'reencode.go')
-rw-r--r-- | reencode.go | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/reencode.go b/reencode.go index f23c85a..4974cb7 100644 --- a/reencode.go +++ b/reencode.go @@ -105,7 +105,7 @@ type ReEncoder struct { lastNonSpaceNonEOF jsonparse.RuneType wasNumber bool curIndent int - uhex [4]byte // "\uABCD"-encoded characters in strings + uhex [3]byte // "\uABCD"-encoded characters in strings fracZeros int64 expZero bool specu *speculation @@ -530,18 +530,13 @@ func (enc *ReEncoder) handleRuneMain(c rune, t jsonparse.RuneType) error { } err = enc.emit(jsonstring.WriteStringChar(enc.out, c, escaper(c, BackslashEscapeShort))) case jsonparse.RuneTypeStringEscUA: - enc.uhex[0], _ = jsonparse.HexToInt(c) + enc.uhex[0] = byte(c) case jsonparse.RuneTypeStringEscUB: - enc.uhex[1], _ = jsonparse.HexToInt(c) + enc.uhex[1] = byte(c) case jsonparse.RuneTypeStringEscUC: - enc.uhex[2], _ = jsonparse.HexToInt(c) + enc.uhex[2] = byte(c) case jsonparse.RuneTypeStringEscUD: - enc.uhex[3], _ = jsonparse.HexToInt(c) - c := 0 | - rune(enc.uhex[0])<<12 | - rune(enc.uhex[1])<<8 | - rune(enc.uhex[2])<<4 | - rune(enc.uhex[3])<<0 + c = hexToRune(enc.uhex[0], enc.uhex[1], enc.uhex[2], byte(c)) err = enc.emit(jsonstring.WriteStringChar(enc.out, c, escaper(c, BackslashEscapeUnicode))) case jsonparse.RuneTypeError: // EOF explicitly stated by .Close() |