diff options
| author | Eli Zaretskii | 2002-03-16 17:29:48 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2002-03-16 17:29:48 +0000 |
| commit | efe7ebe3d5b03ee3d77c735eee119b71ddb2a59e (patch) | |
| tree | 0c641a176743a5eda53b01a95288b54b59155499 | |
| parent | 7dd4fd43473fff089d69ac2ed17ede7077b2d90a (diff) | |
| download | emacs-efe7ebe3d5b03ee3d77c735eee119b71ddb2a59e.tar.gz emacs-efe7ebe3d5b03ee3d77c735eee119b71ddb2a59e.zip | |
(po-content-type-charset-alist): Convert the
car of each association to a string.
(po-find-file-coding-system-guts): If the charset matches a name
of a codepage, set up that codepage and return it as a coding
system to decode the file.
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/textmodes/po.el | 168 |
2 files changed, 99 insertions, 78 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f9d6ed979ae..fcf16f7e341 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -3,8 +3,13 @@ | |||
| 3 | * international/codepage.el (codepage-setup): Don't define a | 3 | * international/codepage.el (codepage-setup): Don't define a |
| 4 | codepage if it is already defined. | 4 | codepage if it is already defined. |
| 5 | 5 | ||
| 6 | * textmodes/po.el (po-find-charset): Search for the Charset= | 6 | * textmodes/po.el (po-content-type-charset-alist): Convert the |
| 7 | header even if we've read less than 4KB. | 7 | car of each association to a string. |
| 8 | (po-find-file-coding-system-guts): If the charset matches a name | ||
| 9 | of a codepage, set up that codepage and return it as a coding | ||
| 10 | system to decode the file. | ||
| 11 | (po-find-charset): Search for the Charset= header even if we've | ||
| 12 | read less than 4KB. | ||
| 8 | <top-level>: Remove the setup for all known codepages: it seems | 13 | <top-level>: Remove the setup for all known codepages: it seems |
| 9 | to cause crashes in the CCL driver. | 14 | to cause crashes in the CCL driver. |
| 10 | 15 | ||
diff --git a/lisp/textmodes/po.el b/lisp/textmodes/po.el index 93446be8f82..6de22b54734 100644 --- a/lisp/textmodes/po.el +++ b/lisp/textmodes/po.el | |||
| @@ -34,77 +34,77 @@ | |||
| 34 | 34 | ||
| 35 | (defconst po-content-type-charset-alist | 35 | (defconst po-content-type-charset-alist |
| 36 | '(; Note: Emacs 21 doesn't support all encodings, thus the missing entries. | 36 | '(; Note: Emacs 21 doesn't support all encodings, thus the missing entries. |
| 37 | (ASCII . undecided) | 37 | ("ASCII" . undecided) |
| 38 | (ANSI_X3.4-1968 . undecided) | 38 | ("ANSI_X3.4-1968" . undecided) |
| 39 | (US-ASCII . undecided) | 39 | ("US-ASCII" . undecided) |
| 40 | (ISO-8859-1 . iso-8859-1) | 40 | ("ISO-8859-1" . iso-8859-1) |
| 41 | (ISO_8859-1 . iso-8859-1) | 41 | ("ISO_8859-1" . iso-8859-1) |
| 42 | (ISO-8859-2 . iso-8859-2) | 42 | ("ISO-8859-2" . iso-8859-2) |
| 43 | (ISO_8859-2 . iso-8859-2) | 43 | ("ISO_8859-2" . iso-8859-2) |
| 44 | (ISO-8859-3 . iso-8859-3) | 44 | ("ISO-8859-3" . iso-8859-3) |
| 45 | (ISO_8859-3 . iso-8859-3) | 45 | ("ISO_8859-3" . iso-8859-3) |
| 46 | (ISO-8859-4 . iso-8859-4) | 46 | ("ISO-8859-4" . iso-8859-4) |
| 47 | (ISO_8859-4 . iso-8859-4) | 47 | ("ISO_8859-4" . iso-8859-4) |
| 48 | (ISO-8859-5 . iso-8859-5) | 48 | ("ISO-8859-5" . iso-8859-5) |
| 49 | (ISO_8859-5 . iso-8859-5) | 49 | ("ISO_8859-5" . iso-8859-5) |
| 50 | ;(ISO-8859-6 . ??) | 50 | ;("ISO-8859-6" . ??) |
| 51 | ;(ISO_8859-6 . ??) | 51 | ;("ISO_8859-6" . ??) |
| 52 | (ISO-8859-7 . iso-8859-7) | 52 | ("ISO-8859-7" . iso-8859-7) |
| 53 | (ISO_8859-7 . iso-8859-7) | 53 | ("ISO_8859-7" . iso-8859-7) |
| 54 | (ISO-8859-8 . iso-8859-8) | 54 | ("ISO-8859-8" . iso-8859-8) |
| 55 | (ISO_8859-8 . iso-8859-8) | 55 | ("ISO_8859-8" . iso-8859-8) |
| 56 | (ISO-8859-9 . iso-8859-9) | 56 | ("ISO-8859-9" . iso-8859-9) |
| 57 | (ISO_8859-9 . iso-8859-9) | 57 | ("ISO_8859-9" . iso-8859-9) |
| 58 | ;(ISO-8859-13 . ??) | 58 | ;("ISO-8859-13" . ??) |
| 59 | ;(ISO_8859-13 . ??) | 59 | ;("ISO_8859-13" . ??) |
| 60 | (ISO-8859-15 . iso-8859-15) ; requires Emacs 21 | 60 | ("ISO-8859-15" . iso-8859-15) ; requires Emacs 21 |
| 61 | (ISO_8859-15 . iso-8859-15) ; requires Emacs 21 | 61 | ("ISO_8859-15" . iso-8859-15) ; requires Emacs 21 |
| 62 | (KOI8-R . koi8-r) | 62 | ("KOI8-R" . koi8-r) |
| 63 | ;(KOI8-U . ??) | 63 | ;("KOI8-U" . ??) |
| 64 | (CP437 . cp437) ; requires Emacs 20 | 64 | ("CP437" . cp437) ; requires Emacs 20 |
| 65 | (CP775 . cp775) ; requires Emacs 20 | 65 | ("CP775" . cp775) ; requires Emacs 20 |
| 66 | (CP850 . cp850) ; requires Emacs 20 | 66 | ("CP850" . cp850) ; requires Emacs 20 |
| 67 | (CP852 . cp852) ; requires Emacs 20 | 67 | ("CP852" . cp852) ; requires Emacs 20 |
| 68 | (CP855 . cp855) ; requires Emacs 20 | 68 | ("CP855" . cp855) ; requires Emacs 20 |
| 69 | ;(CP856 . ??) | 69 | ;("CP856" . ??) |
| 70 | (CP857 . cp857) ; requires Emacs 20 | 70 | ("CP857" . cp857) ; requires Emacs 20 |
| 71 | (CP861 . cp861) ; requires Emacs 20 | 71 | ("CP861" . cp861) ; requires Emacs 20 |
| 72 | (CP862 . cp862) ; requires Emacs 20 | 72 | ("CP862" . cp862) ; requires Emacs 20 |
| 73 | (CP864 . cp864) ; requires Emacs 20 | 73 | ("CP864" . cp864) ; requires Emacs 20 |
| 74 | (CP865 . cp865) ; requires Emacs 20 | 74 | ("CP865" . cp865) ; requires Emacs 20 |
| 75 | (CP866 . cp866) ; requires Emacs 21 | 75 | ("CP866" . cp866) ; requires Emacs 21 |
| 76 | (CP869 . cp869) ; requires Emacs 20 | 76 | ("CP869" . cp869) ; requires Emacs 20 |
| 77 | ;(CP874 . ??) | 77 | ;("CP874" . ??) |
| 78 | ;(CP922 . ??) | 78 | ;("CP922" . ??) |
| 79 | ;(CP932 . ??) | 79 | ;("CP932" . ??) |
| 80 | ;(CP943 . ??) | 80 | ;("CP943" . ??) |
| 81 | ;(CP949 . ??) | 81 | ;("CP949" . ??) |
| 82 | ;(CP950 . ??) | 82 | ;("CP950" . ??) |
| 83 | ;(CP1046 . ??) | 83 | ;("CP1046" . ??) |
| 84 | ;(CP1124 . ??) | 84 | ;("CP1124" . ??) |
| 85 | ;(CP1129 . ??) | 85 | ;("CP1129" . ??) |
| 86 | (CP1250 . cp1250) ; requires Emacs 20 | 86 | ("CP1250" . cp1250) ; requires Emacs 20 |
| 87 | (CP1251 . cp1251) ; requires Emacs 20 | 87 | ("CP1251" . cp1251) ; requires Emacs 20 |
| 88 | (CP1252 . iso-8859-1) ; approximation | 88 | ("CP1252" . iso-8859-1) ; approximation |
| 89 | (CP1253 . cp1253) ; requires Emacs 20 | 89 | ("CP1253" . cp1253) ; requires Emacs 20 |
| 90 | (CP1254 . iso-8859-9) ; approximation | 90 | ("CP1254" . iso-8859-9) ; approximation |
| 91 | (CP1255 . iso-8859-8) ; approximation | 91 | ("CP1255" . iso-8859-8) ; approximation |
| 92 | ;(CP1256 . ??) | 92 | ;("CP1256" . ??) |
| 93 | (CP1257 . cp1257) ; requires Emacs 20 | 93 | ("CP1257" . cp1257) ; requires Emacs 20 |
| 94 | (GB2312 . cn-gb-2312) ; also named 'gb2312' in XEmacs 21 or Emacs 21 | 94 | ("GB2312" . cn-gb-2312) ; also named 'gb2312' in XEmacs 21 or Emacs 21 |
| 95 | ; also named 'euc-cn' in Emacs 20 or Emacs 21 | 95 | ; also named 'euc-cn' in Emacs 20 or Emacs 21 |
| 96 | (EUC-JP . euc-jp) | 96 | ("EUC-JP" . euc-jp) |
| 97 | (EUC-KR . euc-kr) | 97 | ("EUC-KR" . euc-kr) |
| 98 | ;(EUC-TW . ??) | 98 | ;("EUC-TW" . ??) |
| 99 | (BIG5 . big5) | 99 | ("BIG5" . big5) |
| 100 | ;(BIG5-HKSCS . ??) | 100 | ;("BIG5-HKSCS" . ??) |
| 101 | ;(GBK . ??) | 101 | ;("GBK" . ??) |
| 102 | ;(GB18030 . ??) | 102 | ;("GB18030" . ??) |
| 103 | (SHIFT_JIS . shift_jis) | 103 | ("SHIFT_JIS" . shift_jis) |
| 104 | ;(JOHAB . ??) | 104 | ;("JOHAB" . ??) |
| 105 | (TIS-620 . tis-620) ; requires Emacs 20 or Emacs 21 | 105 | ("TIS-620" . tis-620) ; requires Emacs 20 or Emacs 21 |
| 106 | (VISCII . viscii) ; requires Emacs 20 or Emacs 21 | 106 | ("VISCII" . viscii) ; requires Emacs 20 or Emacs 21 |
| 107 | (UTF-8 . utf-8) ; requires Mule-UCS in Emacs 20, or Emacs 21 | 107 | ("UTF-8" . utf-8) ; requires Mule-UCS in Emacs 20, or Emacs 21 |
| 108 | ) | 108 | ) |
| 109 | "How to convert a GNU libc/libiconv canonical charset name as seen in | 109 | "How to convert a GNU libc/libiconv canonical charset name as seen in |
| 110 | Content-Type into a Mule coding system.") | 110 | Content-Type into a Mule coding system.") |
| @@ -148,12 +148,28 @@ Called through file-coding-system-alist, before the file is visited for real." | |||
| 148 | (with-temp-buffer | 148 | (with-temp-buffer |
| 149 | (let* ((coding-system-for-read 'no-conversion) | 149 | (let* ((coding-system-for-read 'no-conversion) |
| 150 | (charset (or (po-find-charset filename) "ascii")) | 150 | (charset (or (po-find-charset filename) "ascii")) |
| 151 | (charset-upper (intern (upcase charset))) | 151 | (charset-upper (upcase charset)) |
| 152 | (charset-lower (intern (downcase charset)))) | 152 | (charset-lower (downcase charset)) |
| 153 | (list (or (cdr (assq charset-upper po-content-type-charset-alist)) | 153 | (candidate |
| 154 | (if (memq charset-lower (coding-system-list)) | 154 | (cdr (assoc charset-upper po-content-type-charset-alist))) |
| 155 | charset-lower | 155 | (try (or candidate (intern-soft charset-lower)))) |
| 156 | 'no-conversion))))))) | 156 | (list (cond ((and try (coding-system-p try)) |
| 157 | try) | ||
| 158 | ((and try | ||
| 159 | (string-match "\\`cp[1-9][0-9][0-9]?\\'" | ||
| 160 | (symbol-name try)) | ||
| 161 | (assoc (substring (symbol-name try) 2) | ||
| 162 | (cp-supported-codepages))) | ||
| 163 | (codepage-setup (substring (symbol-name try) 2)) | ||
| 164 | try) | ||
| 165 | ((and (string-match "\\`cp[1-9][0-9][0-9]?\\'" | ||
| 166 | charset-lower) | ||
| 167 | (assoc (substring charset-lower 2) | ||
| 168 | (cp-supported-codepages))) | ||
| 169 | (codepage-setup (substring charset-lower 2)) | ||
| 170 | (intern charset-lower)) | ||
| 171 | (t | ||
| 172 | 'no-conversion))))))) | ||
| 157 | 173 | ||
| 158 | ;;;###autoload | 174 | ;;;###autoload |
| 159 | (defun po-find-file-coding-system (arg-list) | 175 | (defun po-find-file-coding-system (arg-list) |