Mercurial > emacs
changeset 20803:0fa2183c587d
(ENCODE_ISO_CHARACTER): Pay attention to
CODING_FLAG_ISO_USE_ROMAN and CODING_FLAG_ISO_USE_OLDJIS.
(code_convert_region1): New function.
(Fdecode_coding_region): Call code_convert_region1.
(Fencode_coding_region): Likewise.
(code_convert_string1): New function.
(Fdecode_coding_string): Call code_convert_string1.
(Fencode_coding_string): Likewise.
/
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 30 Jan 1998 11:05:41 +0000 |
parents | 8cd0a6343a84 |
children | 14fa73136e64 |
files | src/coding.c |
diffstat | 1 files changed, 49 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/src/coding.c Fri Jan 30 11:05:41 1998 +0000 +++ b/src/coding.c Fri Jan 30 11:05:41 1998 +0000 @@ -1551,12 +1551,22 @@ else \ charset_alt = charset; \ if (CHARSET_DIMENSION (charset_alt) == 1) \ - ENCODE_ISO_CHARACTER_DIMENSION1 (charset_alt, c1); \ + { \ + if (charset == CHARSET_ASCII \ + && coding->flags & CODING_FLAG_ISO_USE_ROMAN) \ + charset_alt = charset_latin_jisx0201; \ + ENCODE_ISO_CHARACTER_DIMENSION1 (charset_alt, c1); \ + } \ else \ - ENCODE_ISO_CHARACTER_DIMENSION2 (charset_alt, c1, c2); \ + { \ + if (charset == charset_jisx0208 \ + && coding->flags & CODING_FLAG_ISO_USE_OLDJIS) \ + charset_alt = charset_jisx0208_1978; \ + ENCODE_ISO_CHARACTER_DIMENSION2 (charset_alt, c1, c2); \ + } \ if (! COMPOSING_P (coding->composing)) \ coding->consumed_char++; \ - } while (0) + } while (0) /* Produce designation and invocation codes at a place pointed by DST to use CHARSET. The element `spec.iso2022' of *CODING is updated. @@ -4344,17 +4354,13 @@ !NILP (highest)); } -DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region, - 3, 3, "r\nzCoding system: ", - "Decode the current region by specified coding system.\n\ -When called from a program, takes three arguments:\n\ -START, END, and CODING-SYSTEM. START and END are buffer positions.\n\ -Return length of decoded text.") - (start, end, coding_system) +Lisp_Object +code_convert_region1 (start, end, coding_system, encodep) Lisp_Object start, end, coding_system; + int encodep; { struct coding_system coding; - int from, to; + int from, to, len; CHECK_NUMBER_COERCE_MARKER (start, 0); CHECK_NUMBER_COERCE_MARKER (end, 1); @@ -4371,7 +4377,20 @@ error ("Invalid coding system: %s", XSYMBOL (coding_system)->name->data); coding.mode |= CODING_MODE_LAST_BLOCK; - return code_convert_region (from, to, &coding, 0, 1); + len = code_convert_region (from, to, &coding, encodep, 1); + return make_number (len); +} + +DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region, + 3, 3, "r\nzCoding system: ", + "Decode the current region by specified coding system.\n\ +When called from a program, takes three arguments:\n\ +START, END, and CODING-SYSTEM. START and END are buffer positions.\n\ +Return length of decoded text.") + (start, end, coding_system) + Lisp_Object start, end, coding_system; +{ + return code_convert_region1 (start, end, coding_system, 0); } DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region, @@ -4383,34 +4402,13 @@ (start, end, coding_system) Lisp_Object start, end, coding_system; { - struct coding_system coding; - int from, to; - - CHECK_NUMBER_COERCE_MARKER (start, 0); - CHECK_NUMBER_COERCE_MARKER (end, 1); - CHECK_SYMBOL (coding_system, 2); - - validate_region (&start, &end); - from = XFASTINT (start); - to = XFASTINT (end); - - if (NILP (coding_system)) - return make_number (to - from); - - if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) - error ("Invalid coding system: %s", XSYMBOL (coding_system)->name->data); - - coding.mode |= CODING_MODE_LAST_BLOCK; - return code_convert_region (from, to, &coding, 1, 1); + return code_convert_region1 (start, end, coding_system, 1); } -DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, - 2, 3, 0, - "Decode STRING which is encoded in CODING-SYSTEM, and return the result.\n\ -Optional arg NOCOPY non-nil means it is ok to return STRING itself\n\ -if the decoding operation is trivial.") - (string, coding_system, nocopy) +Lisp_Object +code_convert_string1 (string, coding_system, nocopy, encodep) Lisp_Object string, coding_system, nocopy; + int encodep; { struct coding_system coding; @@ -4424,7 +4422,18 @@ error ("Invalid coding system: %s", XSYMBOL (coding_system)->name->data); coding.mode |= CODING_MODE_LAST_BLOCK; - return code_convert_string (string, &coding, 0, !NILP (nocopy)); + return code_convert_string (string, &coding, encodep, !NILP (nocopy)); +} + +DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, + 2, 3, 0, + "Decode STRING which is encoded in CODING-SYSTEM, and return the result.\n\ +Optional arg NOCOPY non-nil means it is ok to return STRING itself\n\ +if the decoding operation is trivial.") + (string, coding_system, nocopy) + Lisp_Object string, coding_system, nocopy; +{ + return code_convert_string1(string, coding_system, nocopy, 0); } DEFUN ("encode-coding-string", Fencode_coding_string, Sencode_coding_string, @@ -4435,20 +4444,9 @@ (string, coding_system, nocopy) Lisp_Object string, coding_system, nocopy; { - struct coding_system coding; - - CHECK_STRING (string, 0); - CHECK_SYMBOL (coding_system, 1); - - if (NILP (coding_system)) - return (NILP (nocopy) ? Fcopy_sequence (string) : string); - - if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) - error ("Invalid coding system: %s", XSYMBOL (coding_system)->name->data); - - coding.mode |= CODING_MODE_LAST_BLOCK; - return code_convert_string (string, &coding, 1, !NILP (nocopy)); + return code_convert_string1(string, coding_system, nocopy, 1); } + DEFUN ("decode-sjis-char", Fdecode_sjis_char, Sdecode_sjis_char, 1, 1, 0, "Decode a JISX0208 character of shift-jis encoding.\n\