From: Lars Ingebrigtsen Date: Wed, 18 Oct 2017 22:25:22 +0000 (+0200) Subject: Encode non-ASCII SVG texts X-Git-Tag: emacs-27.0.90~6242 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=38738f61bc16f5792220467730634598ac92f149;p=emacs.git Encode non-ASCII SVG texts * lisp/svg.el (svg--encode-text): Encode non-ASCII texts. --- diff --git a/lisp/svg.el b/lisp/svg.el index 6a0c49b4698..8639bf11243 100644 --- a/lisp/svg.el +++ b/lisp/svg.el @@ -157,7 +157,21 @@ otherwise. IMAGE-TYPE should be a MIME image type, like (dom-node 'text `(,@(svg--arguments svg args)) - text))) + (svg--encode-text text)))) + +(defun svg--encode-text (text) + ;; Apparently the SVG renderer needs to have all non-ASCII + ;; characters encoded. + (with-temp-buffer + (insert text) + (goto-char (point-min)) + (while (not (eobp)) + (let ((char (following-char))) + (if (<= char 128) + (forward-char 1) + (delete-char 1) + (insert "&#" (format "%d" char) ";")))) + (buffer-string))) (defun svg--append (svg node) (let ((old (and (dom-attr node 'id)