Mercurial > emacs
comparison lisp/international/code-pages.el @ 52434:14a91089126a
(cp-make-translation-table)
(cp-valid-codes): Made defsubsts.
(cp-fix-safe-chars): Deleted.
(mule-diag): Don't require.
(windows-1251, windows-1252): Removed to cyrillic.el/european.el.
(top-level): Check for defined coding system when defining
cp... aliases. Change w32-add-charset-info test to avoid warning.
(non-iso-charset-alist): Defvar when compiling.
(cp-make-coding-system): Doc fix.
author | Dave Love <fx@gnu.org> |
---|---|
date | Thu, 04 Sep 2003 16:59:00 +0000 |
parents | 695cf19ef79e |
children | af41ec2032d0 |
comparison
equal
deleted
inserted
replaced
52433:875975e6fae5 | 52434:14a91089126a |
---|---|
31 ;; codepage.el. The utility `cp-make-coding-system' derives them from | 31 ;; codepage.el. The utility `cp-make-coding-system' derives them from |
32 ;; simple tables. | 32 ;; simple tables. |
33 | 33 |
34 ;; Those covered are: cp437, cp737, cp720, cp775, cp850, cp851, cp852, | 34 ;; Those covered are: cp437, cp737, cp720, cp775, cp850, cp851, cp852, |
35 ;; cp855, cp857, cp860, cp861, cp862, cp863, cp864, cp865, cp866, | 35 ;; cp855, cp857, cp860, cp861, cp862, cp863, cp864, cp865, cp866, |
36 ;; cp869, cp874, cp1125, windows-1250, windows-1251, windows-1252, | 36 ;; cp869, cp874, cp1125, windows-1250, windows-1253, windows-1254, |
37 ;; windows-1253, windows-1254, windows-1255, windows-1256, | 37 ;; windows-1255, windows-1256, windows-1257, windows-1258, next, |
38 ;; windows-1257, windows-1258, next, koi8-u, iso-8859-6, | 38 ;; iso-8859-6, iso-8859-10, iso-8859-11, iso-8859-16, koi8-t, |
39 ;; iso-8859-10, iso-8859-11, iso-8859-16, koi8-t, georgian-ps. This | 39 ;; georgian-ps. This is meant to include all the single-byte ones |
40 ;; is meant to include all the single-byte ones relevant to GNU (used | 40 ;; relevant to GNU (used in glibc-defined locales); we don't yet get |
41 ;; in glibc-defined locales); we don't yet get all the multibyte ones | 41 ;; all the multibyte ones in base Emacs. |
42 ;; in base Emacs. | |
43 | 42 |
44 ;; Note that various of these can clash with definitions in | 43 ;; Note that various of these can clash with definitions in |
45 ;; codepage.el; we try to avoid damage from that. A few CPs from | 44 ;; codepage.el; we try to avoid damage from that. A few CPs from |
46 ;; codepage.el (770, 773, 774) aren't covered (in the absence of | 45 ;; codepage.el (770, 773, 774) aren't covered (in the absence of |
47 ;; translation tables to Unicode). | 46 ;; translation tables to Unicode). |
52 ;; splitting the file and autoloading the coding systems if/when my | 51 ;; splitting the file and autoloading the coding systems if/when my |
53 ;; (or similar) autoloading code is installed. | 52 ;; (or similar) autoloading code is installed. |
54 | 53 |
55 ;;; Code: | 54 ;;; Code: |
56 | 55 |
57 (defun cp-make-translation-table (v) | 56 ;; The defsubsts here are just so that language files can use |
57 ;; `cp-make-coding-system' and not require functions from this file | |
58 ;; at runtime. | |
59 | |
60 (defsubst cp-make-translation-table (v) | |
58 "Return a translation table made from 128-long vector V. | 61 "Return a translation table made from 128-long vector V. |
59 V comprises characters encodable by mule-utf-8." | 62 V comprises characters encodable by mule-utf-8." |
60 (let ((encoding-vector (make-vector 256 0))) | 63 (let ((encoding-vector (make-vector 256 0))) |
61 (dotimes (i 128) | 64 (dotimes (i 128) |
62 (aset encoding-vector i i)) | 65 (aset encoding-vector i i)) |
73 (if c1 ; we encode that unicode | 76 (if c1 ; we encode that unicode |
74 (aset encode-table c c1))))) | 77 (aset encode-table c c1))))) |
75 ucs-mule-to-mule-unicode) | 78 ucs-mule-to-mule-unicode) |
76 tab))) | 79 tab))) |
77 | 80 |
78 (defun cp-valid-codes (v) | 81 (defsubst cp-valid-codes (v) |
79 "Derive a valid-codes list for translation vector V. | 82 "Derive a valid-codes list for translation vector V. |
80 See `make-coding-system'." | 83 See `make-coding-system'." |
81 (let (pairs | 84 (let (pairs |
82 (i 128) ; index into v | 85 (i 128) ; index into v |
83 (start 0) ; start of a valid range | 86 (start 0) ; start of a valid range |
92 (setq start nil)) | 95 (setq start nil)) |
93 (setq i (1+ i))) | 96 (setq i (1+ i))) |
94 (if start (push (cons start end) pairs)) | 97 (if start (push (cons start end) pairs)) |
95 (nreverse pairs))) | 98 (nreverse pairs))) |
96 | 99 |
97 (defun cp-fix-safe-chars (cs) | |
98 "This is an obsolete function. | |
99 It exists just for backward compatibility, and it does nothing.") | |
100 (make-obsolete 'cp-fix-safe-chars | |
101 "Unnecessary function. Calling it has no effect." | |
102 "21.3") | |
103 | |
104 ;; Fix things that have been, or might be, done by codepage.el. | 100 ;; Fix things that have been, or might be, done by codepage.el. |
105 (eval-after-load "codepage" | 101 (eval-after-load "codepage" |
106 '(progn | 102 '(progn |
107 | 103 |
108 ;; Semi-dummy version for the stuff in codepage.el which we don't | 104 ;; Semi-dummy version for the stuff in codepage.el which we don't |
143 ;; loading ccl. | 139 ;; loading ccl. |
144 ;;;###autoload | 140 ;;;###autoload |
145 (defmacro cp-make-coding-system (name v &optional doc-string mnemonic) | 141 (defmacro cp-make-coding-system (name v &optional doc-string mnemonic) |
146 "Make coding system NAME for and 8-bit, extended-ASCII character set. | 142 "Make coding system NAME for and 8-bit, extended-ASCII character set. |
147 V is a 128-long vector of characters to translate the upper half of | 143 V is a 128-long vector of characters to translate the upper half of |
148 the charactert set. DOC-STRING and MNEMONIC are used as the | 144 the character set. DOC-STRING and MNEMONIC are used as the |
149 corresponding args of `make-coding-system'. If MNEMONIC isn't given, | 145 corresponding args of `make-coding-system'. If MNEMONIC isn't given, |
150 ?* is used." | 146 ?* is used. |
147 Return an updated `non-iso-charset-alist'." | |
151 (let* ((encoder (intern (format "encode-%s" name))) | 148 (let* ((encoder (intern (format "encode-%s" name))) |
152 (decoder (intern (format "decode-%s" name))) | 149 (decoder (intern (format "decode-%s" name))) |
153 (ccl-decoder | 150 (ccl-decoder |
154 (ccl-compile | 151 (ccl-compile |
155 `(4 | 152 `(4 |
201 (push (cdr elt) l) | 198 (push (cdr elt) l) |
202 (push (car elt) l)) | 199 (push (car elt) l)) |
203 (list l))) | 200 (list l))) |
204 non-iso-charset-alist)))) | 201 non-iso-charset-alist)))) |
205 | 202 |
203 (eval-when-compile (defvar non-iso-charset-alist)) | |
206 | 204 |
207 ;; These tables were mostly derived by running somthing like | 205 ;; These tables were mostly derived by running somthing like |
208 ;; `recode -f cpxxx/..utf-8' on a binary file filled by | 206 ;; `recode -f cpxxx/..utf-8' on a binary file filled by |
209 ;; `(dotimes (i 128) (insert ?? ?\\ (+ 128 i) ?\n))' and then | 207 ;; `(dotimes (i 128) (insert ?? ?\\ (+ 128 i) ?\n))' and then |
210 ;; exchanging the ?\� entries for nil. iconv was used instead in some | 208 ;; exchanging the ?\� entries for nil. iconv was used instead in some |
2570 ?\ű | 2568 ?\ű |
2571 ?\ü | 2569 ?\ü |
2572 ?\ý | 2570 ?\ý |
2573 ?\ţ | 2571 ?\ţ |
2574 ?\˙]) | 2572 ?\˙]) |
2575 | |
2576 ;; be_BY, bg_BG | |
2577 (cp-make-coding-system | |
2578 windows-1251 | |
2579 [?\Ђ | |
2580 ?\Ѓ | |
2581 ?\‚ | |
2582 ?\ѓ | |
2583 ?\„ | |
2584 ?\… | |
2585 ?\† | |
2586 ?\‡ | |
2587 ?\€ | |
2588 ?\‰ | |
2589 ?\Љ | |
2590 ?\‹ | |
2591 ?\Њ | |
2592 ?\Ќ | |
2593 ?\Ћ | |
2594 ?\Џ | |
2595 ?\ђ | |
2596 ?\‘ | |
2597 ?\’ | |
2598 ?\“ | |
2599 ?\” | |
2600 ?\• | |
2601 ?\– | |
2602 ?\— | |
2603 nil | |
2604 ?\™ | |
2605 ?\љ | |
2606 ?\› | |
2607 ?\њ | |
2608 ?\ќ | |
2609 ?\ћ | |
2610 ?\џ | |
2611 ?\ | |
2612 ?\Ў | |
2613 ?\ў | |
2614 ?\Ј | |
2615 ?\¤ | |
2616 ?\Ґ | |
2617 ?\¦ | |
2618 ?\§ | |
2619 ?\Ё | |
2620 ?\© | |
2621 ?\Є | |
2622 ?\« | |
2623 ?\¬ | |
2624 ?\ | |
2625 ?\® | |
2626 ?\Ї | |
2627 ?\° | |
2628 ?\± | |
2629 ?\І | |
2630 ?\і | |
2631 ?\ґ | |
2632 ?\µ | |
2633 ?\¶ | |
2634 ?\· | |
2635 ?\ё | |
2636 ?\№ | |
2637 ?\є | |
2638 ?\» | |
2639 ?\ј | |
2640 ?\Ѕ | |
2641 ?\ѕ | |
2642 ?\ї | |
2643 ?\А | |
2644 ?\Б | |
2645 ?\В | |
2646 ?\Г | |
2647 ?\Д | |
2648 ?\Е | |
2649 ?\Ж | |
2650 ?\З | |
2651 ?\И | |
2652 ?\Й | |
2653 ?\К | |
2654 ?\Л | |
2655 ?\М | |
2656 ?\Н | |
2657 ?\О | |
2658 ?\П | |
2659 ?\Р | |
2660 ?\С | |
2661 ?\Т | |
2662 ?\У | |
2663 ?\Ф | |
2664 ?\Х | |
2665 ?\Ц | |
2666 ?\Ч | |
2667 ?\Ш | |
2668 ?\Щ | |
2669 ?\Ъ | |
2670 ?\Ы | |
2671 ?\Ь | |
2672 ?\Э | |
2673 ?\Ю | |
2674 ?\Я | |
2675 ?\а | |
2676 ?\б | |
2677 ?\в | |
2678 ?\г | |
2679 ?\д | |
2680 ?\е | |
2681 ?\ж | |
2682 ?\з | |
2683 ?\и | |
2684 ?\й | |
2685 ?\к | |
2686 ?\л | |
2687 ?\м | |
2688 ?\н | |
2689 ?\о | |
2690 ?\п | |
2691 ?\р | |
2692 ?\с | |
2693 ?\т | |
2694 ?\у | |
2695 ?\ф | |
2696 ?\х | |
2697 ?\ц | |
2698 ?\ч | |
2699 ?\ш | |
2700 ?\щ | |
2701 ?\ъ | |
2702 ?\ы | |
2703 ?\ь | |
2704 ?\э | |
2705 ?\ю | |
2706 ?\я] | |
2707 nil ?b) | |
2708 | |
2709 (cp-make-coding-system | |
2710 windows-1252 | |
2711 [?\€ | |
2712 nil | |
2713 ?\‚ | |
2714 ?\ƒ | |
2715 ?\„ | |
2716 ?\… | |
2717 ?\† | |
2718 ?\‡ | |
2719 ?\ˆ | |
2720 ?\‰ | |
2721 ?\Š | |
2722 ?\‹ | |
2723 ?\Œ | |
2724 nil | |
2725 ?\Ž | |
2726 ?\ž | |
2727 nil | |
2728 ?\‘ | |
2729 ?\’ | |
2730 ?\“ | |
2731 ?\” | |
2732 ?\• | |
2733 ?\– | |
2734 ?\— | |
2735 ?\˜ | |
2736 ?\™ | |
2737 ?\š | |
2738 ?\› | |
2739 ?\œ | |
2740 nil | |
2741 nil | |
2742 ?\Ÿ | |
2743 ?\ | |
2744 ?\¡ | |
2745 ?\¢ | |
2746 ?\£ | |
2747 ?\¤ | |
2748 ?\¥ | |
2749 ?\¦ | |
2750 ?\§ | |
2751 ?\¨ | |
2752 ?\© | |
2753 ?\ª | |
2754 ?\« | |
2755 ?\¬ | |
2756 ?\ | |
2757 ?\® | |
2758 ?\¯ | |
2759 ?\° | |
2760 ?\± | |
2761 ?\² | |
2762 ?\³ | |
2763 ?\´ | |
2764 ?\µ | |
2765 ?\¶ | |
2766 ?\· | |
2767 ?\¸ | |
2768 ?\¹ | |
2769 ?\º | |
2770 ?\» | |
2771 ?\¼ | |
2772 ?\½ | |
2773 ?\¾ | |
2774 ?\¿ | |
2775 ?\À | |
2776 ?\Á | |
2777 ?\Â | |
2778 ?\Ã | |
2779 ?\Ä | |
2780 ?\Å | |
2781 ?\Æ | |
2782 ?\Ç | |
2783 ?\È | |
2784 ?\É | |
2785 ?\Ê | |
2786 ?\Ë | |
2787 ?\Ì | |
2788 ?\Í | |
2789 ?\Î | |
2790 ?\Ï | |
2791 ?\Ð | |
2792 ?\Ñ | |
2793 ?\Ò | |
2794 ?\Ó | |
2795 ?\Ô | |
2796 ?\Õ | |
2797 ?\Ö | |
2798 ?\× | |
2799 ?\Ø | |
2800 ?\Ù | |
2801 ?\Ú | |
2802 ?\Û | |
2803 ?\Ü | |
2804 ?\Ý | |
2805 ?\Þ | |
2806 ?\ß | |
2807 ?\à | |
2808 ?\á | |
2809 ?\â | |
2810 ?\ã | |
2811 ?\ä | |
2812 ?\å | |
2813 ?\æ | |
2814 ?\ç | |
2815 ?\è | |
2816 ?\é | |
2817 ?\ê | |
2818 ?\ë | |
2819 ?\ì | |
2820 ?\í | |
2821 ?\î | |
2822 ?\ï | |
2823 ?\ð | |
2824 ?\ñ | |
2825 ?\ò | |
2826 ?\ó | |
2827 ?\ô | |
2828 ?\õ | |
2829 ?\ö | |
2830 ?\÷ | |
2831 ?\ø | |
2832 ?\ù | |
2833 ?\ú | |
2834 ?\û | |
2835 ?\ü | |
2836 ?\ý | |
2837 ?\þ | |
2838 ?\ÿ]) | |
2839 | 2573 |
2840 (cp-make-coding-system | 2574 (cp-make-coding-system |
2841 windows-1253 | 2575 windows-1253 |
2842 [?\€ | 2576 [?\€ |
2843 nil | 2577 nil |
4747 "ISO-8859-11. This is `thai-tis620' with the addition of no-break-space.") | 4481 "ISO-8859-11. This is `thai-tis620' with the addition of no-break-space.") |
4748 | 4482 |
4749 (dotimes (i 8) | 4483 (dotimes (i 8) |
4750 (let ((w (intern (format "windows-125%d" i))) | 4484 (let ((w (intern (format "windows-125%d" i))) |
4751 (c (intern (format "cp125%d" i)))) | 4485 (c (intern (format "cp125%d" i)))) |
4752 (define-coding-system-alias c w) | 4486 (if (coding-system-p c) ; 1251 is in cyrillic.el |
4487 (define-coding-system-alias c w)) | |
4753 ;; Compatibility with codepage.el, though cp... are not the | 4488 ;; Compatibility with codepage.el, though cp... are not the |
4754 ;; canonical names. | 4489 ;; canonical names. |
4755 (push (assoc w non-iso-charset-alist) non-iso-charset-alist))) | 4490 (push (assoc w non-iso-charset-alist) non-iso-charset-alist))) |
4756 | 4491 |
4757 ;; Use Unicode font under Windows. Jason Rumney fecit. | 4492 ;; Use Unicode font under Windows. Jason Rumney fecit. |
4758 (if (and (fboundp 'w32-add-charset-info) | 4493 (if (fboundp 'w32-add-charset-info) |
4759 (not (boundp 'w32-unicode-charset-defined))) | 4494 (unless (boundp 'w32-unicode-charset-defined) |
4760 (w32-add-charset-info "iso10646-1" 'w32-charset-ansi t)) | 4495 (w32-add-charset-info "iso10646-1" 'w32-charset-ansi t))) |
4761 | 4496 |
4762 (provide 'code-pages) | 4497 (provide 'code-pages) |
4763 | 4498 |
4764 ;;; arch-tag: 8b6e3c73-b271-4198-866d-ea6d0ceff1b2 | 4499 ;;; arch-tag: 8b6e3c73-b271-4198-866d-ea6d0ceff1b2 |
4765 ;;; code-pages.el ends here | 4500 ;;; code-pages.el ends here |