* mu4e-utils: cleanup some outlook encoding garbage

This commit is contained in:
djcb 2012-06-26 22:49:01 +03:00
parent b16aab5b3d
commit 7816436b2a
1 changed files with 16 additions and 5 deletions

View File

@ -372,8 +372,19 @@ function prefers the text part, but this can be changed by setting
(buffer-string)))
(t ;; otherwise, an empty body
""))))
;; and finally, remove some crap from the remaining string.
(replace-regexp-in-string "[  ]" " " body nil nil nil)))
;; and finally, remove some crap from the remaining string; it seems
;; esp. outlook lies about its encoding (ie., it says 'iso-8859-1' but
;; really it's 'windows-1252'), thus giving us these funky chars. here, we
;; either remove them, or replace with 'what-was-meant' (heuristically)
(with-temp-buffer
(insert body)
(goto-char (point-min))
(while (re-search-forward "[  ’]" nil t)
(replace-match
(cond
((string= (match-string 0) "’") "'")
(t ""))))
(buffer-string))))