help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fixing M$ character codes


From: Jym Dyer
Subject: Re: fixing M$ character codes
Date: 04 Jul 2004 07:08:50 -0700

=v= I think ideally the code would parse headers to figure out
whether the brain damaged quotes are supposed to be ISO-Latin,
Windows-1252, UTF-8, or whatever.  But for now I just use a
sledgehammer and convert any and all needlessly-8bit characters
to their 7bit equivalents.

=v= The code I use is below.  I suppose someday I ought to make
them more comprehensive, but for now I just add what I need
along the way.  (Warning:  this converts all know quotes and
dashes to ASCII equivalents, but also convert centered dots to
asterisks, which isn't exactly an equivalent.)
    <_Jym_>


(defun jym.de8 ()
  "Turn 8bit characters into 7bit equivalents."
  (interactive)
  (mapcar
   (function (lambda (old_and_new)
    (save-excursion (apply 'query-replace old_and_new))))
   '(("­" "-")
     ("¹" "'")
     ("²" "''")
     ("³" "``")
     ("·" "*")
     ("…" "...")
     ("‹" "--")
     ("Œ" "`")
     ("‘" "`")
     ("“" "``")                 ; = 0x93
     ("”" "''")                 ; = 0x94
     ("•" "*")
     ("–" "-")                  ; = 0x96
     ("—" "--")                 ; = 0x97
     ("˜" "`")
     ("™" "'")
     ("œ" "``")
     ("" "''")
     ("â€" "") )))
  ;mapcar;
;defun jym.de8;

(defun jym.de8qp ()
  "Turn quoted printable 8bit into 7bit equivalents."
  (interactive)
  (mapcar
   (function (lambda (old_and_new)
    (save-excursion (apply 'query-replace old_and_new))))
   '(("=\n" "")
     ;("=E2=80=94" "--")
     ("=E2=80=99" "'")                  ; UTF-8
     ("=E2=80=9C" "``")                 ; UTF-8
     ("=E2=80=9D" "''")                 ; UTF-8
     ("=0D\n" "\n")                     ; = \r\n
     ("=20\n" "\n")
     ("=2E" ".")
     ("=3F" "?")
     ("=46" "F")
     ("=5B" "[")
     ("=5D" "]")
     ("=8B" "--")
     ("=8C" "`")
     ("=91" "`")
     ("=92" "'")
     ("=93" "``")                       ; = 0223
     ("=94" "''")
     ("=96" "-")                        ; = 0226
     ("=97" "--")                       ; = 0227
     ("=A0" " ")
     ("=A5" "'")
     ("=AD" "--")
     ("=AE" "\"")
     ("=B2" "``")
     ("=B3" "''")
     ("=B9" "'")) ))
  ;mapcar;
;defun jym.de8qp;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]