summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2015-10-23 12:23:23 +0300
committerEli Zaretskii <eliz@gnu.org>2015-10-23 12:23:23 +0300
commit0f7334147d23ad2792523f59a968fb44c820fa35 (patch)
treee7f38eff3da53e9f6143584ddb983a43c43968fd /lisp
parentb3d065d2efecfe88d1c07c344c8b5d4501d0a6bb (diff)
downloademacs-0f7334147d23ad2792523f59a968fb44c820fa35.tar.gz
Decode the HTML source when displaying it in EWW
* lisp/net/eww.el (eww-view-source): Decode the HTML source according to its headers.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/eww.el9
1 files changed, 9 insertions, 0 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index bda4e0cfec2..6a315496fe0 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -564,6 +564,15 @@ Currently this means either text/html or application/xhtml+xml."
(delete-region (point-min) (point-max))
(insert (or source "no source"))
(goto-char (point-min))
+ ;; Decode the source and set the buffer's encoding according
+ ;; to what the HTML source specifies in its 'charset' header,
+ ;; if any.
+ (let ((cs (find-auto-coding "" (point-max))))
+ (when (consp cs)
+ (setq cs (car cs))
+ (when (coding-system-p cs)
+ (decode-coding-region (point-min) (point-max) cs)
+ (setq buffer-file-coding-system last-coding-system-used))))
(when (fboundp 'html-mode)
(html-mode))))
(view-buffer buf)))