Commit 37deb14c authored by Johan Sundström's avatar Johan Sundström Committed by Per Cederqvist

Added lyskom-view-text-convert-UTF-8-to-ISO-8859-1, in celebration of the...

Added lyskom-view-text-convert-UTF-8-to-ISO-8859-1, in celebration of the upcoming three year anniversary of the kom-view-text-hook lyskom-view-text-convert-ISO-646-SE-to-ISO-8859-1. Again not the best way of solving a problem, but at least it requires no external packages.
parent f6a1c4a7
2005-01-26 Johan Sundstrm <jhs@lysator.liu.se>
* view-text.el
(lyskom-view-text-convert-UTF-8-to-ISO-8859-1): New function
that, when put in `kom-view-text-hook', translates basic UTF-8
characters available in ISO-8859-1 to their such counterparts.
* swedish-strings.el, english-strings.el (lyskom-message): Added
the string `reformat-utf-8'.
2005-01-23 David Byers <byers@lysator.liu.se>
* Release of 0.48.
......
......@@ -1486,6 +1486,8 @@ On since %#8s%#9s")
(reformat-deswascii . "was swascii")
(reformat-utf-8 . "was UTF-8")
(reformat-rot13 . "rot13")
(need-library . "The \"%#1s\" package is required for this command.\n")
......
......@@ -1536,6 +1536,8 @@ Uppkopplad sedan %#8s%#9s")
(reformat-rot13 . "rot13")
(reformat-utf-8 . "var UTF-8")
(need-library . "Paketet \"%#1s\" behvs fr att utfra detta kommando.\n")
(calc-expression . "Uttryck: ")
......
......@@ -441,6 +441,40 @@ when put in your `kom-view-text-hook'."
(lyskom-signal-reformatted-text 'reformat-rot13))
(defun lyskom-view-text-convert-UTF-8-to-ISO-8859-1 ()
"Display räksmörgÃ¥s as räksmörgås if the text has charset=utf-8,
unless we are reviewing without conversion. More precisely, the latin
1 characters are converted from their utf-8 normal form. Yet another
useful function to put in your `kom-view-text-hook'."
(let* ((cti (lyskom-get-aux-item
(text-stat->aux-items lyskom-view-text-text-stat) 1))
(content-type (and cti (aux-item->data (car cti)))))
(when (and (string-match "charset\\s-*=\\s-*utf-?8" content-type)
(not (lyskom-viewing-noconversion)))
(let* ((was (aref (cdr lyskom-view-text-text) 1)) ; original text version
(txt nil) ; converted-text-to-be
(get "Ã.") ; "[ÂÃ][\200-\277]", if emacsen would grok 8-bit ranges
(old 0)
(got (string-match get was))
; (set nil)
(chr nil))
(when got
(lyskom-signal-reformatted-text 'reformat-utf-8)
(while got
(setq ; set (aref was got)
chr (aref was (1+ got))
txt (nconc txt (list (substring was old got)
(char-to-string ;(if (eq set ?Â) chr
(+ chr 64))))
old (+ 2 got)
got (string-match get was old)))
(setq txt (apply 'concat (nconc txt (list (substring was old)))))
(setq txt (replace-in-string txt "Â" "")) ; sigh
(aset (cdr lyskom-view-text-text) 1 txt))))))
;(add-hook 'kom-view-text-hook 'lyskom-view-text-convert-UTF-8-to-ISO-8859-1)
(defun lyskom-view-text-convert-ISO-646-SE-to-ISO-8859-1 ()
"Display r{ksm|rg}s as räksmörgås unless the text is an imported mail
or we are reviewing without conversion. In other words, the characters
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment