diff options
| author | Kenichi Handa | 1999-01-14 01:20:35 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1999-01-14 01:20:35 +0000 |
| commit | 55ab7be3ac27989754fd3dc21748bcf9ef9d4910 (patch) | |
| tree | b06e512854d09fc7835d31daaec5a477eb17f85a /src/coding.c | |
| parent | d3fcfdea92c23d3a20ed7020cdd6f310bb74fb03 (diff) | |
| download | emacs-55ab7be3ac27989754fd3dc21748bcf9ef9d4910.tar.gz emacs-55ab7be3ac27989754fd3dc21748bcf9ef9d4910.zip | |
(Fdecode_sjis_char): Decode Japanese Katakana character
correctly.
(Fencode_sjis_char): Encode Japanese Katakana character correctly.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/src/coding.c b/src/coding.c index 3c3588252e2..cff2d2b30da 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -2096,7 +2096,7 @@ encode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes) | |||
| 2096 | if (!NILP (translation_table) \ | 2096 | if (!NILP (translation_table) \ |
| 2097 | && ((c_alt = translate_char (translation_table, \ | 2097 | && ((c_alt = translate_char (translation_table, \ |
| 2098 | -1, (charset), c1, c2)) >= 0)) \ | 2098 | -1, (charset), c1, c2)) >= 0)) \ |
| 2099 | SPLIT_CHAR (c_alt, charset_alt, c1, c2); \ | 2099 | SPLIT_CHAR (c_alt, charset_alt, c1, c2); \ |
| 2100 | if (charset_alt == CHARSET_ASCII || charset_alt < 0) \ | 2100 | if (charset_alt == CHARSET_ASCII || charset_alt < 0) \ |
| 2101 | DECODE_CHARACTER_ASCII (c1); \ | 2101 | DECODE_CHARACTER_ASCII (c1); \ |
| 2102 | else if (CHARSET_DIMENSION (charset_alt) == 1) \ | 2102 | else if (CHARSET_DIMENSION (charset_alt) == 1) \ |
| @@ -5018,8 +5018,7 @@ code_convert_string_norecord (string, coding_system, encodep) | |||
| 5018 | } | 5018 | } |
| 5019 | 5019 | ||
| 5020 | DEFUN ("decode-sjis-char", Fdecode_sjis_char, Sdecode_sjis_char, 1, 1, 0, | 5020 | DEFUN ("decode-sjis-char", Fdecode_sjis_char, Sdecode_sjis_char, 1, 1, 0, |
| 5021 | "Decode a JISX0208 character of shift-jis encoding.\n\ | 5021 | "Decode a Japanese character which has CODE in shift_jis encoding.\n\ |
| 5022 | CODE is the character code in SJIS.\n\ | ||
| 5023 | Return the corresponding character.") | 5022 | Return the corresponding character.") |
| 5024 | (code) | 5023 | (code) |
| 5025 | Lisp_Object code; | 5024 | Lisp_Object code; |
| @@ -5029,14 +5028,26 @@ Return the corresponding character.") | |||
| 5029 | 5028 | ||
| 5030 | CHECK_NUMBER (code, 0); | 5029 | CHECK_NUMBER (code, 0); |
| 5031 | s1 = (XFASTINT (code)) >> 8, s2 = (XFASTINT (code)) & 0xFF; | 5030 | s1 = (XFASTINT (code)) >> 8, s2 = (XFASTINT (code)) & 0xFF; |
| 5032 | DECODE_SJIS (s1, s2, c1, c2); | 5031 | if (s1 == 0) |
| 5033 | XSETFASTINT (val, MAKE_NON_ASCII_CHAR (charset_jisx0208, c1, c2)); | 5032 | { |
| 5033 | if (s2 < 0xA0 || s2 > 0xDF) | ||
| 5034 | error ("Invalid Shift JIS code: %s", XFASTINT (code)); | ||
| 5035 | XSETFASTINT (val, MAKE_NON_ASCII_CHAR (charset_katakana_jisx0201, s2, 0)); | ||
| 5036 | } | ||
| 5037 | else | ||
| 5038 | { | ||
| 5039 | if ((s1 < 0x80 || s1 > 0x9F && s1 < 0xE0 || s1 > 0xEF) | ||
| 5040 | || (s2 < 0x40 || s2 == 0x7F || s2 > 0xFC)) | ||
| 5041 | error ("Invalid Shift JIS code: %s", XFASTINT (code)); | ||
| 5042 | DECODE_SJIS (s1, s2, c1, c2); | ||
| 5043 | XSETFASTINT (val, MAKE_NON_ASCII_CHAR (charset_jisx0208, c1, c2)); | ||
| 5044 | } | ||
| 5034 | return val; | 5045 | return val; |
| 5035 | } | 5046 | } |
| 5036 | 5047 | ||
| 5037 | DEFUN ("encode-sjis-char", Fencode_sjis_char, Sencode_sjis_char, 1, 1, 0, | 5048 | DEFUN ("encode-sjis-char", Fencode_sjis_char, Sencode_sjis_char, 1, 1, 0, |
| 5038 | "Encode a JISX0208 character CHAR to SJIS coding system.\n\ | 5049 | "Encode a Japanese character CHAR to shift_jis encoding.\n\ |
| 5039 | Return the corresponding character code in SJIS.") | 5050 | Return the corresponding code in SJIS.") |
| 5040 | (ch) | 5051 | (ch) |
| 5041 | Lisp_Object ch; | 5052 | Lisp_Object ch; |
| 5042 | { | 5053 | { |
| @@ -5045,13 +5056,20 @@ Return the corresponding character code in SJIS.") | |||
| 5045 | 5056 | ||
| 5046 | CHECK_NUMBER (ch, 0); | 5057 | CHECK_NUMBER (ch, 0); |
| 5047 | SPLIT_CHAR (XFASTINT (ch), charset, c1, c2); | 5058 | SPLIT_CHAR (XFASTINT (ch), charset, c1, c2); |
| 5048 | if (charset == charset_jisx0208) | 5059 | if (charset == charset_jisx0208 |
| 5060 | && c1 > 0x20 && c1 < 0x7F && c2 > 0x20 && c2 < 0x7F) | ||
| 5049 | { | 5061 | { |
| 5050 | ENCODE_SJIS (c1, c2, s1, s2); | 5062 | ENCODE_SJIS (c1, c2, s1, s2); |
| 5051 | XSETFASTINT (val, (s1 << 8) | s2); | 5063 | XSETFASTINT (val, (s1 << 8) | s2); |
| 5052 | } | 5064 | } |
| 5065 | else if (charset == charset_katakana_jisx0201 | ||
| 5066 | && c1 > 0x20 && c2 < 0xE0) | ||
| 5067 | { | ||
| 5068 | XSETFASTINT (val, c1 | 0x80); | ||
| 5069 | } | ||
| 5053 | else | 5070 | else |
| 5054 | XSETFASTINT (val, 0); | 5071 | error ("Can't encode to shift_jis: %d", XFASTINT (ch)); |
| 5072 | |||
| 5055 | return val; | 5073 | return val; |
| 5056 | } | 5074 | } |
| 5057 | 5075 | ||