@@ -1448,7 +1448,7 @@ final class JsonWriter private[jsoniter_scala](
1448
1448
}
1449
1449
1450
1450
private [this ] def writeEscapedOrEncodedString (s : String , from : Int , pos : Int , escapedChars : Array [Byte ]): Int =
1451
- if (config.escapeUnicode) writeEscapedString(s, from, s.length, pos, limit - 13 , escapedChars)
1451
+ if (config.escapeUnicode) writeEscapedString(s, from, s.length, pos, limit - 13 , escapedChars, lowerCaseHexDigits )
1452
1452
else writeEncodedString(s, from, s.length, pos, limit - 7 , escapedChars)
1453
1453
1454
1454
@ tailrec
@@ -1466,7 +1466,7 @@ final class JsonWriter private[jsoniter_scala](
1466
1466
buf(pos) = '\\ '
1467
1467
buf(pos + 1 ) = esc
1468
1468
writeEncodedString(s, from + 1 , to, pos + 2 , posLim, escapedChars)
1469
- } else writeEncodedString(s, from + 1 , to, writeEscapedUnicode(ch1.toByte, pos, buf), posLim, escapedChars)
1469
+ } else writeEncodedString(s, from + 1 , to, writeEscapedUnicode(ch1.toByte, pos, buf, lowerCaseHexDigits ), posLim, escapedChars)
1470
1470
} else if (ch1 < 0x800 ) { // 00000bbbbbaaaaaa (UTF-16 char) -> 110bbbbb 10aaaaaa (UTF-8 bytes)
1471
1471
buf(pos) = (ch1 >> 6 | 0xC0 ).toByte
1472
1472
buf(pos + 1 ) = (ch1 & 0x3F | 0x80 ).toByte
@@ -1492,30 +1492,30 @@ final class JsonWriter private[jsoniter_scala](
1492
1492
}
1493
1493
1494
1494
@ tailrec
1495
- private [this ] def writeEscapedString (s : String , from : Int , to : Int , pos : Int , posLim : Int , escapedChars : Array [Byte ]): Int =
1495
+ private [this ] def writeEscapedString (s : String , from : Int , to : Int , pos : Int , posLim : Int , escapedChars : Array [Byte ], ds : Array [ Short ] ): Int =
1496
1496
if (from >= to) pos
1497
- else if (pos >= posLim) writeEscapedString(s, from, to, flushAndGrowBuf(13 , pos), limit - 12 , escapedChars)
1497
+ else if (pos >= posLim) writeEscapedString(s, from, to, flushAndGrowBuf(13 , pos), limit - 12 , escapedChars, ds )
1498
1498
else {
1499
1499
val ch1 = s.charAt(from).toInt
1500
1500
if (ch1 < 0x80 ) {
1501
1501
val esc = escapedChars(ch1)
1502
1502
if (esc == 0 ) {
1503
1503
buf(pos) = ch1.toByte
1504
- writeEscapedString(s, from + 1 , to, pos + 1 , posLim, escapedChars)
1504
+ writeEscapedString(s, from + 1 , to, pos + 1 , posLim, escapedChars, ds )
1505
1505
} else if (esc > 0 ) {
1506
1506
buf(pos) = '\\ '
1507
1507
buf(pos + 1 ) = esc
1508
- writeEscapedString(s, from + 1 , to, pos + 2 , posLim, escapedChars)
1509
- } else writeEscapedString(s, from + 1 , to, writeEscapedUnicode(ch1.toByte, pos, buf), posLim, escapedChars)
1508
+ writeEscapedString(s, from + 1 , to, pos + 2 , posLim, escapedChars, ds )
1509
+ } else writeEscapedString(s, from + 1 , to, writeEscapedUnicode(ch1.toByte, pos, buf, ds ), posLim, escapedChars, ds )
1510
1510
} else if ((ch1 & 0xF800 ) != 0xD800 ) {
1511
- writeEscapedString(s, from + 1 , to, writeEscapedUnicode(ch1, pos, buf), posLim, escapedChars)
1511
+ writeEscapedString(s, from + 1 , to, writeEscapedUnicode(ch1, pos, buf, ds ), posLim, escapedChars, ds )
1512
1512
} else {
1513
1513
var ch2 = 0
1514
1514
if (ch1 >= 0xDC00 || from + 1 >= to || {
1515
1515
ch2 = s.charAt(from + 1 ).toInt
1516
1516
(ch2 & 0xFC00 ) != 0xDC00
1517
1517
}) illegalSurrogateError()
1518
- writeEscapedString(s, from + 2 , to, writeEscapedUnicode(ch2, writeEscapedUnicode(ch1, pos, buf), buf), posLim, escapedChars)
1518
+ writeEscapedString(s, from + 2 , to, writeEscapedUnicode(ch2, writeEscapedUnicode(ch1, pos, buf, ds ), buf, ds ), posLim, escapedChars, ds )
1519
1519
}
1520
1520
}
1521
1521
@@ -1533,10 +1533,10 @@ final class JsonWriter private[jsoniter_scala](
1533
1533
buf(pos) = '\\ '
1534
1534
buf(pos + 1 ) = esc
1535
1535
pos += 2
1536
- } else pos = writeEscapedUnicode(ch.toByte, pos, buf)
1536
+ } else pos = writeEscapedUnicode(ch.toByte, pos, buf, lowerCaseHexDigits )
1537
1537
} else if (config.escapeUnicode) {
1538
1538
if ((ch & 0xF800 ) == 0xD800 ) illegalSurrogateError()
1539
- pos = writeEscapedUnicode(ch, pos, buf)
1539
+ pos = writeEscapedUnicode(ch, pos, buf, lowerCaseHexDigits )
1540
1540
} else if (ch < 0x800 ) { // 00000bbbbbaaaaaa (UTF-16 char) -> 110bbbbb 10aaaaaa (UTF-8 bytes)
1541
1541
buf(pos) = (ch >> 6 | 0xC0 ).toByte
1542
1542
buf(pos + 1 ) = (ch & 0x3F | 0x80 ).toByte
@@ -1551,8 +1551,7 @@ final class JsonWriter private[jsoniter_scala](
1551
1551
count = pos + 1
1552
1552
}
1553
1553
1554
- private [this ] def writeEscapedUnicode (ch : Int , pos : Int , buf : Array [Byte ]): Int = {
1555
- val ds = lowerCaseHexDigits
1554
+ private [this ] def writeEscapedUnicode (ch : Int , pos : Int , buf : Array [Byte ], ds : Array [Short ]): Int = {
1556
1555
buf(pos) = '\\ '
1557
1556
buf(pos + 1 ) = 'u'
1558
1557
val d1 = ds(ch >> 8 )
@@ -1564,8 +1563,7 @@ final class JsonWriter private[jsoniter_scala](
1564
1563
pos + 6
1565
1564
}
1566
1565
1567
- private [this ] def writeEscapedUnicode (b : Byte , pos : Int , buf : Array [Byte ]): Int = {
1568
- val ds = lowerCaseHexDigits
1566
+ private [this ] def writeEscapedUnicode (b : Byte , pos : Int , buf : Array [Byte ], ds : Array [Short ]): Int = {
1569
1567
buf(pos) = '\\ '
1570
1568
buf(pos + 1 ) = 'u'
1571
1569
buf(pos + 2 ) = '0'
0 commit comments