summaryrefslogtreecommitdiff
path: root/reencode.go
diff options
context:
space:
mode:
Diffstat (limited to 'reencode.go')
-rw-r--r--reencode.go15
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()