[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master cbe3f5f 2/2: Touch up previous shr-dom-to-xml encod
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master cbe3f5f 2/2: Touch up previous shr-dom-to-xml encoding change |
Date: |
Thu, 3 Oct 2019 10:15:48 -0400 (EDT) |
branch: master
commit cbe3f5f7203b54a7e0ffc65dee83289f1a966077
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
Touch up previous shr-dom-to-xml encoding change
* lisp/net/shr.el (shr-dom-to-xml): Include an XML declaration if
we're encoding the data.
(shr-parse-image-data): Add comment about why encoding is necessary.
---
lisp/net/shr.el | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index cf32763..628cc17 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1180,7 +1180,9 @@ Return a string with image data."
(eq content-type 'image/svg+xml))
(setq data
;; Note that libxml2 doesn't parse everything perfectly,
- ;; so glitches may occur during this transformation.
+ ;; so glitches may occur during this transformation. And
+ ;; encode as utf-8: There may be text (and other elements)
+ ;; that are non-ASCII.
(shr-dom-to-xml
(libxml-parse-xml-region (point) (point-max)) 'utf-8)))
;; SVG images often do not have a specified foreground/background
@@ -1342,7 +1344,10 @@ ones, in case fg and bg are nil."
(with-temp-buffer
(shr-dom-print dom)
(when charset
- (encode-coding-region (point-min) (point-max) charset))
+ (encode-coding-region (point-min) (point-max) charset)
+ (goto-char (point-min))
+ (insert (format "<?xml version=\"1.0\" encoding=\"%s\"?>\n"
+ charset)))
(buffer-string)))
(defun shr-dom-print (dom)