Adjust UTF-16 parsing
This commit is contained in:
parent
44f98163d9
commit
e43371da87
|
@ -38,11 +38,19 @@ template unescape*(buf: var string; capture: string) =
|
||||||
of 't': add(buf, char 0x09)
|
of 't': add(buf, char 0x09)
|
||||||
of '"': add(buf, char 0x22)
|
of '"': add(buf, char 0x22)
|
||||||
of 'u':
|
of 'u':
|
||||||
var r: int32
|
var
|
||||||
|
long: uint32
|
||||||
|
short: uint16
|
||||||
inc(i)
|
inc(i)
|
||||||
discard parseHex(capture, r, i, 4)
|
discard parseHex(capture, short, i, 4)
|
||||||
inc(i, 3)
|
inc(i, 3)
|
||||||
add(buf, Rune r)
|
long = uint32(short)
|
||||||
|
if capture[i] == 'u':
|
||||||
|
inc(i)
|
||||||
|
discard parseHex(capture, short, i, 4)
|
||||||
|
inc(i, 3)
|
||||||
|
long = (long shl 16) or uint32(short)
|
||||||
|
add(buf, long.Rune.toUtf8)
|
||||||
else:
|
else:
|
||||||
validate(false)
|
validate(false)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue