DEFUN ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0,
"Return t if OBJECT is nil or a coding-system.\n\
-See document of make-coding-system for coding-system object.")
+See the documentation of `make-coding-system' for information\n\
+about coding-system objects.")
(obj)
Lisp_Object obj;
{
DEFUN ("check-coding-system", Fcheck_coding_system, Scheck_coding_system,
1, 1, 0,
"Check validity of CODING-SYSTEM.\n\
-If valid, return CODING-SYSTEM, else `coding-system-error' is signaled.\n\
-CODING-SYSTEM is valid if it is a symbol and has \"coding-system\" property.\n\
+If valid, return CODING-SYSTEM, else signal a `coding-system-error' error.\n\
+It is valid if it is a symbol with a non-nil `coding-system' property.\n\
The value of property should be a vector of length 5.")
(coding_system)
Lisp_Object coding_system;
while (1)
Fsignal (Qcoding_system_error, Fcons (coding_system, Qnil));
}
-
+\f
DEFUN ("detect-coding-region", Fdetect_coding_region, Sdetect_coding_region,
2, 2, 0,
"Detect coding system of the text in the region between START and END.\n\
return val;
}
-
+\f
/* Scan text in the region between *BEGP and *ENDP, skip characters
which we never have to encode to (iff ENCODEP is 1) or decode from
coding system CODING at the head and tail, then set BEGP and ENDP
*endp = end_addr;
return;
}
-
+\f
/* Encode into or decode from (according to ENCODEP) coding system CODING
the text between char positions B and E. */
TEMP_SET_PT_BOTH (shrunk_beg, shrunk_beg_byte);
- if (encodep)
- /* If we just encoded, treat the result as single-byte. */
- insert_1_both (buf, produced, produced, 0, 1, 0);
- else
- insert (buf, produced);
+ /* We let the number of characters in the result
+ be computed in accord with enable-multilibyte-characters
+ even when encoding. Otherwise the buffer contents
+ will be inconsistent. */
+ insert (buf, produced);
del_range_byte (PT_BYTE, PT_BYTE + shrunk_len_byte, 1);
return make_number (len);
}
+DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region,
+ 3, 3, "r\nzCoding system: ",
+ "Decode current region by specified coding system.\n\
+When called from a program, takes three arguments:\n\
+START, END, and CODING-SYSTEM. START END are buffer positions.\n\
+Return length of decoded text.")
+ (b, e, coding_system)
+ Lisp_Object b, e, coding_system;
+{
+ struct coding_system coding;
+
+ CHECK_NUMBER_COERCE_MARKER (b, 0);
+ CHECK_NUMBER_COERCE_MARKER (e, 1);
+ CHECK_SYMBOL (coding_system, 2);
+
+ if (NILP (coding_system))
+ return make_number (XFASTINT (e) - XFASTINT (b));
+ if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
+ error ("Invalid coding-system: %s", XSYMBOL (coding_system)->name->data);
+
+ return code_convert_region (b, e, &coding, 0);
+}
+
+DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region,
+ 3, 3, "r\nzCoding system: ",
+ "Encode current region by specified coding system.\n\
+When called from a program, takes three arguments:\n\
+START, END, and CODING-SYSTEM. START END are buffer positions.\n\
+Return length of encoded text.")
+ (b, e, coding_system)
+ Lisp_Object b, e, coding_system;
+{
+ struct coding_system coding;
+
+ CHECK_NUMBER_COERCE_MARKER (b, 0);
+ CHECK_NUMBER_COERCE_MARKER (e, 1);
+ CHECK_SYMBOL (coding_system, 2);
+
+ if (NILP (coding_system))
+ return make_number (XFASTINT (e) - XFASTINT (b));
+ if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
+ error ("Invalid coding-system: %s", XSYMBOL (coding_system)->name->data);
+
+ return code_convert_region (b, e, &coding, 1);
+}
+\f
/* Encode or decode (according to ENCODEP) the text of string STR
using coding CODING. If NOCOPY is nil, we never return STR
itself, but always a copy. If NOCOPY is non-nil, we return STR
return make_string (buf, head_skip + produced + tail_skip);
}
-DEFUN ("decode-coding-region", Fdecode_coding_region, Sdecode_coding_region,
- 3, 3, "r\nzCoding system: ",
- "Decode current region by specified coding system.\n\
-When called from a program, takes three arguments:\n\
-START, END, and CODING-SYSTEM. START END are buffer positions.\n\
-Return length of decoded text.")
- (b, e, coding_system)
- Lisp_Object b, e, coding_system;
-{
- struct coding_system coding;
-
- CHECK_NUMBER_COERCE_MARKER (b, 0);
- CHECK_NUMBER_COERCE_MARKER (e, 1);
- CHECK_SYMBOL (coding_system, 2);
-
- if (NILP (coding_system))
- return make_number (XFASTINT (e) - XFASTINT (b));
- if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
- error ("Invalid coding-system: %s", XSYMBOL (coding_system)->name->data);
-
- return code_convert_region (b, e, &coding, 0);
-}
-
-DEFUN ("encode-coding-region", Fencode_coding_region, Sencode_coding_region,
- 3, 3, "r\nzCoding system: ",
- "Encode current region by specified coding system.\n\
-When called from a program, takes three arguments:\n\
-START, END, and CODING-SYSTEM. START END are buffer positions.\n\
-Return length of encoded text.")
- (b, e, coding_system)
- Lisp_Object b, e, coding_system;
-{
- struct coding_system coding;
-
- CHECK_NUMBER_COERCE_MARKER (b, 0);
- CHECK_NUMBER_COERCE_MARKER (e, 1);
- CHECK_SYMBOL (coding_system, 2);
-
- if (NILP (coding_system))
- return make_number (XFASTINT (e) - XFASTINT (b));
- if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
- error ("Invalid coding-system: %s", XSYMBOL (coding_system)->name->data);
-
- return code_convert_region (b, e, &coding, 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\
return code_convert_string (string, &coding, 1, nocopy);
}
-
+\f
DEFUN ("decode-sjis-char", Fdecode_sjis_char, Sdecode_sjis_char, 1, 1, 0,
"Decode a JISX0208 character of shift-jis encoding.\n\
CODE is the character code in SJIS.\n\
XSETFASTINT (val, 0);
return val;
}
-
+\f
DEFUN ("set-terminal-coding-system-internal",
Fset_terminal_coding_system_internal,
Sset_terminal_coding_system_internal, 1, 1, 0, "")
DEFUN ("terminal-coding-system",
Fterminal_coding_system, Sterminal_coding_system, 0, 0, 0,
- "Return coding-system of your terminal.")
+ "Return coding system specified for terminal output.")
()
{
return terminal_coding.symbol;
DEFUN ("keyboard-coding-system",
Fkeyboard_coding_system, Skeyboard_coding_system, 0, 0, 0,
- "Return coding-system of what is sent from terminal keyboard.")
+ "Return coding system specified for decoding keyboard input.")
()
{
return keyboard_coding.symbol;