From 9e56d86466b05420d7b504af797e29d62d6a6be8 Mon Sep 17 00:00:00 2001 From: Yrjana Rankka Date: Thu, 28 Jan 2016 17:23:48 +0100 Subject: [PATCH 1/2] Surrogate pair encoding char-codes #x10000-#x1FFFF --- src/encoder.lisp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/encoder.lisp b/src/encoder.lisp index d409362..e001be8 100644 --- a/src/encoder.lisp +++ b/src/encoder.lisp @@ -385,6 +385,11 @@ characters in string S to STREAM." do (write-char #\\ stream) (write-char special stream) else if (< #x1f code #x7f) do (write-char ch stream) + else if (< #x10000 code #x1FFFF) + do (let ((c (- code #x10000))) + (format stream "~C~C" + (code-char (logior #xd800 (ash c -10))) + (code-char (logior #xdc00 (logand c #x3ff))))) else do (let ((special '#.(rassoc-if #'consp +json-lisp-escaped-chars+))) (destructuring-bind (esc . (width . radix)) special From e7726ab1f47e93e7a69e7bcb61801946f26bc5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yrj=C3=A4n=C3=A4=20Rankka?= Date: Thu, 28 Jan 2016 12:05:54 -0500 Subject: [PATCH 2/2] Fixed the fix. Now users escapes. --- src/encoder.lisp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/encoder.lisp b/src/encoder.lisp index e001be8..cbf3b0e 100644 --- a/src/encoder.lisp +++ b/src/encoder.lisp @@ -387,9 +387,9 @@ characters in string S to STREAM." do (write-char ch stream) else if (< #x10000 code #x1FFFF) do (let ((c (- code #x10000))) - (format stream "~C~C" - (code-char (logior #xd800 (ash c -10))) - (code-char (logior #xdc00 (logand c #x3ff))))) + (format stream "\\u~x\\u~x" + (logior #xd800 (ash c -10)) + (logior #xdc00 (logand c #x3ff)))) else do (let ((special '#.(rassoc-if #'consp +json-lisp-escaped-chars+))) (destructuring-bind (esc . (width . radix)) special