mule-charsets.el 1.99 KB
Newer Older
Juanma Barranquero's avatar
Juanma Barranquero committed
1
;; mule-charsets.el -- Generate Mule-original charset maps.
2
;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Kenichi Handa's avatar
Kenichi Handa committed
3 4 5 6 7
;;   National Institute of Advanced Industrial Science and Technology (AIST)
;;   Registration Number H13PRO009

;; This file is part of GNU Emacs.

8
;; GNU Emacs is free software: you can redistribute it and/or modify
Kenichi Handa's avatar
Kenichi Handa committed
9
;; it under the terms of the GNU General Public License as published by
10 11
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
Kenichi Handa's avatar
Kenichi Handa committed
12 13 14 15 16 17 18

;; GNU Emacs 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
19 20
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.

Kenichi Handa's avatar
Kenichi Handa committed
21

22 23 24
(if (not (or (and (= emacs-major-version 21) (= emacs-minor-version 4))
	     (= emacs-major-version 22)))
    (error "Use Emacs of version 21.4 or any of version 22"))
Kenichi Handa's avatar
Kenichi Handa committed
25 26 27 28 29 30 31

(defun func (start end)
  (while (<= start end)
    (let ((split (split-char start))
	  (unicode (encode-char start 'ucs)))
      (if unicode
	  (if (nth 2 split)
32
	      (insert (format "0x%02X%02X 0x%04X\n"
Kenichi Handa's avatar
Kenichi Handa committed
33 34 35 36 37 38 39 40 41 42 43 44 45
			      (nth 1 split) (nth 2 split) unicode))
	    (insert (format "0x%02X 0x%04X\n" (nth 1 split) unicode)))))
    (setq start (1+ start))))

(defconst charset-alist
  '(("MULE-ethiopic.map" . ethiopic)
    ("MULE-ipa.map" . ipa)
    ("MULE-is13194.map" . indian-is13194)
    ("MULE-sisheng.map" . chinese-sisheng)
    ("MULE-tibetan.map" . tibetan)
    ("MULE-lviscii.map" . vietnamese-viscii-lower)
    ("MULE-uviscii.map" . vietnamese-viscii-upper)))

46 47 48 49
(defconst header
  (format
   "# Generated by running amdin/charsets/mule-charsets.el in Emacs %d.%d.\n"
   emacs-major-version emacs-minor-version))
Kenichi Handa's avatar
Kenichi Handa committed
50

51 52 53 54 55
(dolist (elt charset-alist)
  (with-temp-buffer
    (insert header)
    (map-charset-chars 'func (cdr elt))
    (write-file (car elt))))
56