json.writer: make sure we make hex values two digits zero padded.
parent
1ec43d7913
commit
2453a785f7
|
@ -71,3 +71,7 @@ TUPLE: person first-name age ;
|
|||
|
||||
{ "\"\\ud834\\udd1e\"" }
|
||||
[ t json-escape-unicode? [ "𝄞" >json ] with-variable ] unit-test
|
||||
|
||||
{ "\"\\ud800\\udc01\"" }
|
||||
[ t json-escape-unicode? [ "𐀁" >json ] with-variable ] unit-test
|
||||
|
||||
|
|
|
@ -44,12 +44,10 @@ M: json-null stream-json-print
|
|||
|
||||
: json-print-generic-escape-surrogate-pair ( stream char -- stream )
|
||||
0x10000 - [ encode-first ] [ encode-second ] bi
|
||||
"\\u%x%x\\u%x%x" sprintf over stream-write ;
|
||||
"\\u%02x%02x\\u%02x%02x" sprintf over stream-write ;
|
||||
|
||||
: json-print-generic-escape-bmp ( stream char -- stream )
|
||||
"\\u" pick stream-write
|
||||
>hex 4 CHAR: 0 pad-head
|
||||
over stream-write ;
|
||||
"\\u%04x" sprintf over stream-write ;
|
||||
|
||||
: json-print-generic-escape ( stream char -- stream )
|
||||
dup 0xffff > [
|
||||
|
|
Loading…
Reference in New Issue