;;; html-accent.el --- Function that replace accented char by its html representation
;;
;; Filename: html-accent.el
;; Description: Function that replace accented char by its html representation
;; Author: Leonardo de Paula Rosa Piga
;; Copyright (C) 2006, Leonardo de Paula Rosa Piga, all rights reserved.
;; Created: Sex Set 8 16:18:28 BRT 2006
;; Version: 1.0
;; Keywords: i18n, language, accents, html
;; Compatibility: GNU Emacs 21.x
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Installing:
;; Compile it. (M-x byte-compile-file)
;; Copy the html-accent.elc to a folder that is in your load-path library
;;
;; Add the following line to your .emacs
;; (autoload 'html-accent "html-accent" "Accent HTML" t)
;; (autoload 'accent-html "html-accent" "HTML codes to accent" t)
;; Save it, and enjoy
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TODO:
;; Recognize quoted sentences
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
(defun html-accent ()
(interactive)
(setq case-fold-search nil)
(goto-char 1)
(replace-string (format "%c" 160) " ")
(goto-char 1)
(replace-string (format "%c" 161) "¡")
(goto-char 1)
(replace-string (format "%c" 162) "¢")
(goto-char 1)
(replace-string (format "%c" 163) "£")
(goto-char 1)
(replace-string (format "%c" 164) "¤")
(goto-char 1)
(replace-string (format "%c" 165) "¥")
(goto-char 1)
(replace-string (format "%c" 166) "¦")
(goto-char 1)
(replace-string (format "%c" 167) "§")
(goto-char 1)
(replace-string (format "%c" 168) "¨")
(goto-char 1)
(replace-string (format "%c" 169) "©")
(goto-char 1)
(replace-string (format "%c" 170) "ª")
(goto-char 1)
(replace-string (format "%c" 171) "«")
(goto-char 1)
(replace-string (format "%c" 172) "¬")
(goto-char 1)
(replace-string (format "%c" 173) "")
(goto-char 1)
(replace-string (format "%c" 174) "®")
(goto-char 1)
(replace-string (format "%c" 175) "¯")
(goto-char 1)
(replace-string (format "%c" 176) "°")
(goto-char 1)
(replace-string (format "%c" 177) "±")
(goto-char 1)
(replace-string (format "%c" 178) "²")
(goto-char 1)
(replace-string (format "%c" 179) "³")
(goto-char 1)
(replace-string (format "%c" 180) "´")
(goto-char 1)
(replace-string (format "%c" 181) "µ")
(goto-char 1)
(replace-string (format "%c" 182) "¶")
(goto-char 1)
(replace-string (format "%c" 183) "·")
(goto-char 1)
(replace-string (format "%c" 184) "¸")
(goto-char 1)
(replace-string (format "%c" 185) "¹")
(goto-char 1)
(replace-string (format "%c" 186) "º")
(goto-char 1)
(replace-string (format "%c" 187) "»")
(goto-char 1)
(replace-string (format "%c" 188) "¼")
(goto-char 1)
(replace-string (format "%c" 189) "½")
(goto-char 1)
(replace-string (format "%c" 190) "¾")
(goto-char 1)
(replace-string (format "%c" 191) "¿")
(goto-char 1)
(replace-string (format "%c" 192) "À")
(goto-char 1)
(replace-string (format "%c" 193) "Á")
(goto-char 1)
(replace-string (format "%c" 194) "Â")
(goto-char 1)
(replace-string (format "%c" 195) "Ã")
(goto-char 1)
(replace-string (format "%c" 196) "Ä")
(goto-char 1)
(replace-string (format "%c" 197) "Å")
(goto-char 1)
(replace-string (format "%c" 198) "Æ")
(goto-char 1)
(replace-string (format "%c" 199) "Ç")
(goto-char 1)
(replace-string (format "%c" 200) "È")
(goto-char 1)
(replace-string (format "%c" 201) "É")
(goto-char 1)
(replace-string (format "%c" 202) "Ê")
(goto-char 1)
(replace-string (format "%c" 203) "Ë")
(goto-char 1)
(replace-string (format "%c" 204) "Ì")
(goto-char 1)
(replace-string (format "%c" 205) "Í")
(goto-char 1)
(replace-string (format "%c" 206) "Î")
(goto-char 1)
(replace-string (format "%c" 207) "Ï")
(goto-char 1)
(replace-string (format "%c" 208) "Ð")
(goto-char 1)
(replace-string (format "%c" 209) "Ñ")
(goto-char 1)
(replace-string (format "%c" 210) "Ò")
(goto-char 1)
(replace-string (format "%c" 211) "Ó")
(goto-char 1)
(replace-string (format "%c" 212) "Ô")
(goto-char 1)
(replace-string (format "%c" 213) "Õ")
(goto-char 1)
(replace-string (format "%c" 214) "Ö")
(goto-char 1)
(replace-string (format "%c" 215) "×")
(goto-char 1)
(replace-string (format "%c" 216) "Ø")
(goto-char 1)
(replace-string (format "%c" 217) "Ù")
(goto-char 1)
(replace-string (format "%c" 218) "Ú")
(goto-char 1)
(replace-string (format "%c" 219) "Û")
(goto-char 1)
(replace-string (format "%c" 220) "Ü")
(goto-char 1)
(replace-string (format "%c" 221) "Ý")
(goto-char 1)
(replace-string (format "%c" 222) "Þ")
(goto-char 1)
(replace-string (format "%c" 223) "ß")
(goto-char 1)
(replace-string (format "%c" 224) "à")
(goto-char 1)
(replace-string (format "%c" 225) "á")
(goto-char 1)
(replace-string (format "%c" 226) "â")
(goto-char 1)
(replace-string (format "%c" 227) "ã")
(goto-char 1)
(replace-string (format "%c" 228) "ä")
(goto-char 1)
(replace-string (format "%c" 229) "å")
(goto-char 1)
(replace-string (format "%c" 230) "æ")
(goto-char 1)
(replace-string (format "%c" 231) "ç")
(goto-char 1)
(replace-string (format "%c" 232) "è")
(goto-char 1)
(replace-string (format "%c" 233) "é")
(goto-char 1)
(replace-string (format "%c" 234) "ê")
(goto-char 1)
(replace-string (format "%c" 235) "ë")
(goto-char 1)
(replace-string (format "%c" 236) "ì")
(goto-char 1)
(replace-string (format "%c" 237) "í")
(goto-char 1)
(replace-string (format "%c" 238) "î")
(goto-char 1)
(replace-string (format "%c" 239) "ï")
(goto-char 1)
(replace-string (format "%c" 240) "ð")
(goto-char 1)
(replace-string (format "%c" 241) "ñ")
(goto-char 1)
(replace-string (format "%c" 242) "ò")
(goto-char 1)
(replace-string (format "%c" 243) "ó")
(goto-char 1)
(replace-string (format "%c" 244) "ô")
(goto-char 1)
(replace-string (format "%c" 245) "õ")
(goto-char 1)
(replace-string (format "%c" 246) "ö")
(goto-char 1)
(replace-string (format "%c" 247) "÷")
(goto-char 1)
(replace-string (format "%c" 248) "ø")
(goto-char 1)
(replace-string (format "%c" 249) "ù")
(goto-char 1)
(replace-string (format "%c" 250) "ú")
(goto-char 1)
(replace-string (format "%c" 251) "û")
(goto-char 1)
(replace-string (format "%c" 252) "ü")
(goto-char 1)
(replace-string (format "%c" 253) "ý")
(goto-char 1)
(replace-string (format "%c" 254) "þ")
(goto-char 1)
(replace-string (format "%c" 255) "ÿ")
(setq case-fold-search t)
)
(defun accent-html ()
(interactive)
(setq case-fold-search nil)
(goto-char 1)
(replace-string " " (format "%c" 160))
(goto-char 1)
(replace-string "¡" (format "%c" 161))
(goto-char 1)
(replace-string "¢" (format "%c" 162))
(goto-char 1)
(replace-string "£" (format "%c" 163))
(goto-char 1)
(replace-string "¤" (format "%c" 164))
(goto-char 1)
(replace-string "¥" (format "%c" 165))
(goto-char 1)
(replace-string "¦" (format "%c" 166))
(goto-char 1)
(replace-string "§" (format "%c" 167))
(goto-char 1)
(replace-string "¨" (format "%c" 168))
(goto-char 1)
(replace-string "©" (format "%c" 169))
(goto-char 1)
(replace-string "ª" (format "%c" 170))
(goto-char 1)
(replace-string "«" (format "%c" 171))
(goto-char 1)
(replace-string "¬" (format "%c" 172))
(goto-char 1)
(replace-string "" (format "%c" 173))
(goto-char 1)
(replace-string "®" (format "%c" 174))
(goto-char 1)
(replace-string "¯" (format "%c" 175))
(goto-char 1)
(replace-string "°" (format "%c" 176))
(goto-char 1)
(replace-string "±" (format "%c" 177))
(goto-char 1)
(replace-string "²" (format "%c" 178))
(goto-char 1)
(replace-string "³" (format "%c" 179))
(goto-char 1)
(replace-string "´" (format "%c" 180))
(goto-char 1)
(replace-string "µ" (format "%c" 181))
(goto-char 1)
(replace-string "¶" (format "%c" 182))
(goto-char 1)
(replace-string "·" (format "%c" 183))
(goto-char 1)
(replace-string "¸" (format "%c" 184))
(goto-char 1)
(replace-string "¹" (format "%c" 185))
(goto-char 1)
(replace-string "º" (format "%c" 186))
(goto-char 1)
(replace-string "»" (format "%c" 187))
(goto-char 1)
(replace-string "¼" (format "%c" 188))
(goto-char 1)
(replace-string "½" (format "%c" 189))
(goto-char 1)
(replace-string "¾" (format "%c" 190))
(goto-char 1)
(replace-string "¿" (format "%c" 191))
(goto-char 1)
(replace-string "À" (format "%c" 192))
(goto-char 1)
(replace-string "Á" (format "%c" 193))
(goto-char 1)
(replace-string "Â" (format "%c" 194))
(goto-char 1)
(replace-string "Ã" (format "%c" 195))
(goto-char 1)
(replace-string "Ä" (format "%c" 196))
(goto-char 1)
(replace-string "Å" (format "%c" 197))
(goto-char 1)
(replace-string "Æ" (format "%c" 198))
(goto-char 1)
(replace-string "Ç" (format "%c" 199))
(goto-char 1)
(replace-string "È" (format "%c" 200))
(goto-char 1)
(replace-string "É" (format "%c" 201))
(goto-char 1)
(replace-string "Ê" (format "%c" 202))
(goto-char 1)
(replace-string "Ë" (format "%c" 203))
(goto-char 1)
(replace-string "Ì" (format "%c" 204))
(goto-char 1)
(replace-string "Í" (format "%c" 205))
(goto-char 1)
(replace-string "Î" (format "%c" 206))
(goto-char 1)
(replace-string "Ï" (format "%c" 207))
(goto-char 1)
(replace-string "Ð" (format "%c" 208))
(goto-char 1)
(replace-string "Ñ" (format "%c" 209))
(goto-char 1)
(replace-string "Ò" (format "%c" 210))
(goto-char 1)
(replace-string "Ó" (format "%c" 211))
(goto-char 1)
(replace-string "Ô" (format "%c" 212))
(goto-char 1)
(replace-string "Õ" (format "%c" 213))
(goto-char 1)
(replace-string "Ö" (format "%c" 214))
(goto-char 1)
(replace-string "×" (format "%c" 215))
(goto-char 1)
(replace-string "Ø" (format "%c" 216))
(goto-char 1)
(replace-string "Ù" (format "%c" 217))
(goto-char 1)
(replace-string "Ú" (format "%c" 218))
(goto-char 1)
(replace-string "Û" (format "%c" 219))
(goto-char 1)
(replace-string "Ü" (format "%c" 220))
(goto-char 1)
(replace-string "Ý" (format "%c" 221))
(goto-char 1)
(replace-string "Þ" (format "%c" 222))
(goto-char 1)
(replace-string "ß" (format "%c" 223))
(goto-char 1)
(replace-string "à" (format "%c" 224))
(goto-char 1)
(replace-string "á" (format "%c" 225))
(goto-char 1)
(replace-string "â" (format "%c" 226))
(goto-char 1)
(replace-string "ã" (format "%c" 227))
(goto-char 1)
(replace-string "ä" (format "%c" 228))
(goto-char 1)
(replace-string "å" (format "%c" 229))
(goto-char 1)
(replace-string "æ" (format "%c" 230))
(goto-char 1)
(replace-string "ç" (format "%c" 231))
(goto-char 1)
(replace-string "è" (format "%c" 232))
(goto-char 1)
(replace-string "é" (format "%c" 233))
(goto-char 1)
(replace-string "ê" (format "%c" 234))
(goto-char 1)
(replace-string "ë" (format "%c" 235))
(goto-char 1)
(replace-string "ì" (format "%c" 236))
(goto-char 1)
(replace-string "í" (format "%c" 237))
(goto-char 1)
(replace-string "î" (format "%c" 238))
(goto-char 1)
(replace-string "ï" (format "%c" 239))
(goto-char 1)
(replace-string "ð" (format "%c" 240))
(goto-char 1)
(replace-string "ñ" (format "%c" 241))
(goto-char 1)
(replace-string "ò" (format "%c" 242))
(goto-char 1)
(replace-string "ó" (format "%c" 243))
(goto-char 1)
(replace-string "ô" (format "%c" 244))
(goto-char 1)
(replace-string "õ" (format "%c" 245))
(goto-char 1)
(replace-string "ö" (format "%c" 246))
(goto-char 1)
(replace-string "÷" (format "%c" 247))
(goto-char 1)
(replace-string "ø" (format "%c" 248))
(goto-char 1)
(replace-string "ù" (format "%c" 249))
(goto-char 1)
(replace-string "ú" (format "%c" 250))
(goto-char 1)
(replace-string "û" (format "%c" 251))
(goto-char 1)
(replace-string "ü" (format "%c" 252))
(goto-char 1)
(replace-string "ý" (format "%c" 253))
(goto-char 1)
(replace-string "þ" (format "%c" 254))
(goto-char 1)
(replace-string "ÿ" (format "%c" 255))
(setq case-fold-search t)
)