diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2017-10-19 00:25:22 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2017-10-19 00:25:44 +0200 |
commit | 38738f61bc16f5792220467730634598ac92f149 (patch) | |
tree | 3d0ca9f98f8a8d4757d9e93c8e1a5e5f779260da /lisp/svg.el | |
parent | 94281c9a1cc0f756841fdc9b266657853df94a29 (diff) | |
download | emacs-38738f61bc16f5792220467730634598ac92f149.tar.gz emacs-38738f61bc16f5792220467730634598ac92f149.tar.bz2 emacs-38738f61bc16f5792220467730634598ac92f149.zip |
Encode non-ASCII SVG texts
* lisp/svg.el (svg--encode-text): Encode non-ASCII texts.
Diffstat (limited to 'lisp/svg.el')
-rw-r--r-- | lisp/svg.el | 16 |
1 files changed, 15 insertions, 1 deletions
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) |