From 244106a6f21a5c8ee19fd4ea6ba2ab314447d3d9 Mon Sep 17 00:00:00 2001 From: Thomas de Grivel Date: Fri, 19 Jun 2015 20:30:41 +0200 Subject: [PATCH] Fix generation of unicode characters. --- src/codegen.lisp | 7 ++++++- src/constants.lisp | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/codegen.lisp b/src/codegen.lisp index c68cb7b..1087f30 100644 --- a/src/codegen.lisp +++ b/src/codegen.lisp @@ -18,7 +18,12 @@ characters in string S to STREAM." do (write-char #\\ stream) (write-char ch stream) else if (setq special (car (rassoc ch +json-lisp-escaped-chars+))) do (write-char #\\ stream) (write-char special stream) - else do (write-char ch stream)) + else if (< #x1f code #x7f) + do (write-char ch stream) + else + do (let ((special '#.(rassoc-if #'consp +json-lisp-escaped-chars+))) + (destructuring-bind (esc . (width . radix)) special + (format stream "\\~C~V,V,'0R" esc radix width code)))) (write-char quote stream)) ;;; diff --git a/src/constants.lisp b/src/constants.lisp index 858e0c9..f53a629 100644 --- a/src/constants.lisp +++ b/src/constants.lisp @@ -3,6 +3,7 @@ ;;; --- the following is taken from cl-json (defparameter +json-lisp-escaped-chars+ '((#\\ . #\\) + (#\/ . #\/) (#\b . #\Backspace) (#\f . #\ ) (#\n . #\Newline)