1 /* Header for coding system handler.
2 Copyright (C) 2001-2011 Free Software Foundation, Inc.
3 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 2005, 2006, 2007, 2008, 2009, 2010, 2011
5 National Institute of Advanced Industrial Science and Technology (AIST)
6 Registration Number H14PRO021
8 National Institute of Advanced Industrial Science and Technology (AIST)
9 Registration Number H13PRO009
11 This file is part of GNU Emacs.
13 GNU Emacs is free software: you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
18 GNU Emacs is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26 #ifndef EMACS_CODING_H
27 #define EMACS_CODING_H
29 /* Index to arguments of Fdefine_coding_system_internal. */
31 enum define_coding_system_arg_index
35 coding_arg_coding_type
,
36 coding_arg_charset_list
,
37 coding_arg_ascii_compatible_p
,
38 coding_arg_decode_translation_table
,
39 coding_arg_encode_translation_table
,
40 coding_arg_post_read_conversion
,
41 coding_arg_pre_write_conversion
,
42 coding_arg_default_char
,
43 coding_arg_for_unibyte
,
49 enum define_coding_iso2022_arg_index
51 coding_arg_iso2022_initial
= coding_arg_max
,
52 coding_arg_iso2022_reg_usage
,
53 coding_arg_iso2022_request
,
54 coding_arg_iso2022_flags
,
55 coding_arg_iso2022_max
58 enum define_coding_utf8_arg_index
60 coding_arg_utf8_bom
= coding_arg_max
,
64 enum define_coding_utf16_arg_index
66 coding_arg_utf16_bom
= coding_arg_max
,
67 coding_arg_utf16_endian
,
71 enum define_coding_ccl_arg_index
73 coding_arg_ccl_decoder
= coding_arg_max
,
74 coding_arg_ccl_encoder
,
75 coding_arg_ccl_valids
,
79 /* Hash table for all coding systems. Keys are coding system symbols
80 and values are spec vectors of the corresponding coding system. A
81 spec vector has the form [ ATTRS ALIASES EOL-TYPE ]. ATTRS is a
82 vector of attribute of the coding system. ALIASES is a list of
83 aliases (symbols) of the coding system. EOL-TYPE is `unix', `dos',
84 `mac' or a vector of coding systems (symbols). */
86 extern Lisp_Object Vcoding_system_hash_table
;
89 /* Enumeration of coding system type. */
91 enum coding_system_type
97 coding_type_emacs_mule
,
100 coding_type_raw_text
,
101 coding_type_undecided
,
106 /* Enumeration of end-of-line format type. */
108 enum end_of_line_type
110 eol_lf
, /* Line-feed only, same as Emacs' internal
112 eol_crlf
, /* Sequence of carriage-return and
114 eol_cr
, /* Carriage-return only. */
115 eol_any
, /* Accept any of above. Produce line-feed
117 eol_undecided
, /* This value is used to denote that the
118 eol-type is not yet undecided. */
122 /* Enumeration of index to an attribute vector of a coding system. */
124 enum coding_attr_index
126 coding_attr_base_name
,
127 coding_attr_docstring
,
128 coding_attr_mnemonic
,
130 coding_attr_charset_list
,
131 coding_attr_ascii_compat
,
132 coding_attr_decode_tbl
,
133 coding_attr_encode_tbl
,
134 coding_attr_trans_tbl
,
135 coding_attr_post_read
,
136 coding_attr_pre_write
,
137 coding_attr_default_char
,
138 coding_attr_for_unibyte
,
141 coding_attr_category
,
142 coding_attr_safe_charsets
,
144 /* The followings are extra attributes for each type. */
145 coding_attr_charset_valids
,
147 coding_attr_ccl_decoder
,
148 coding_attr_ccl_encoder
,
149 coding_attr_ccl_valids
,
151 coding_attr_iso_initial
,
152 coding_attr_iso_usage
,
153 coding_attr_iso_request
,
154 coding_attr_iso_flags
,
157 coding_attr_utf_16_endian
,
159 coding_attr_emacs_mule_full
,
161 coding_attr_last_index
165 /* Macros to access an element of an attribute vector. */
167 #define CODING_ATTR_BASE_NAME(attrs) AREF (attrs, coding_attr_base_name)
168 #define CODING_ATTR_TYPE(attrs) AREF (attrs, coding_attr_type)
169 #define CODING_ATTR_CHARSET_LIST(attrs) AREF (attrs, coding_attr_charset_list)
170 #define CODING_ATTR_MNEMONIC(attrs) AREF (attrs, coding_attr_mnemonic)
171 #define CODING_ATTR_DOCSTRING(attrs) AREF (attrs, coding_attr_docstring)
172 #define CODING_ATTR_ASCII_COMPAT(attrs) AREF (attrs, coding_attr_ascii_compat)
173 #define CODING_ATTR_DECODE_TBL(attrs) AREF (attrs, coding_attr_decode_tbl)
174 #define CODING_ATTR_ENCODE_TBL(attrs) AREF (attrs, coding_attr_encode_tbl)
175 #define CODING_ATTR_TRANS_TBL(attrs) AREF (attrs, coding_attr_trans_tbl)
176 #define CODING_ATTR_POST_READ(attrs) AREF (attrs, coding_attr_post_read)
177 #define CODING_ATTR_PRE_WRITE(attrs) AREF (attrs, coding_attr_pre_write)
178 #define CODING_ATTR_DEFAULT_CHAR(attrs) AREF (attrs, coding_attr_default_char)
179 #define CODING_ATTR_FOR_UNIBYTE(attrs) AREF (attrs, coding_attr_for_unibyte)
180 #define CODING_ATTR_FLUSHING(attrs) AREF (attrs, coding_attr_flushing)
181 #define CODING_ATTR_PLIST(attrs) AREF (attrs, coding_attr_plist)
182 #define CODING_ATTR_CATEGORY(attrs) AREF (attrs, coding_attr_category)
183 #define CODING_ATTR_SAFE_CHARSETS(attrs)AREF (attrs, coding_attr_safe_charsets)
186 /* Return the name of a coding system specified by ID. */
187 #define CODING_ID_NAME(id) \
188 (HASH_KEY (XHASH_TABLE (Vcoding_system_hash_table), id))
190 /* Return the attribute vector of a coding system specified by ID. */
192 #define CODING_ID_ATTRS(id) \
193 (AREF (HASH_VALUE (XHASH_TABLE (Vcoding_system_hash_table), id), 0))
195 /* Return the list of aliases of a coding system specified by ID. */
197 #define CODING_ID_ALIASES(id) \
198 (AREF (HASH_VALUE (XHASH_TABLE (Vcoding_system_hash_table), id), 1))
200 /* Return the eol-type of a coding system specified by ID. */
202 #define CODING_ID_EOL_TYPE(id) \
203 (AREF (HASH_VALUE (XHASH_TABLE (Vcoding_system_hash_table), id), 2))
206 /* Return the spec vector of CODING_SYSTEM_SYMBOL. */
208 #define CODING_SYSTEM_SPEC(coding_system_symbol) \
209 (Fgethash (coding_system_symbol, Vcoding_system_hash_table, Qnil))
212 /* Return the ID of CODING_SYSTEM_SYMBOL. */
214 #define CODING_SYSTEM_ID(coding_system_symbol) \
215 hash_lookup (XHASH_TABLE (Vcoding_system_hash_table), \
216 coding_system_symbol, NULL)
218 /* Return 1 if CODING_SYSTEM_SYMBOL is a coding system. */
220 #define CODING_SYSTEM_P(coding_system_symbol) \
221 (CODING_SYSTEM_ID (coding_system_symbol) >= 0 \
222 || (! NILP (coding_system_symbol) \
223 && ! NILP (Fcoding_system_p (coding_system_symbol))))
225 /* Check if X is a coding system or not. */
227 #define CHECK_CODING_SYSTEM(x) \
229 if (CODING_SYSTEM_ID (x) < 0 \
230 && NILP (Fcheck_coding_system (x))) \
231 wrong_type_argument (Qcoding_system_p, (x)); \
235 /* Check if X is a coding system or not. If it is, set SEPC to the
236 spec vector of the coding system. */
238 #define CHECK_CODING_SYSTEM_GET_SPEC(x, spec) \
240 spec = CODING_SYSTEM_SPEC (x); \
243 Fcheck_coding_system (x); \
244 spec = CODING_SYSTEM_SPEC (x); \
247 wrong_type_argument (Qcoding_system_p, (x)); \
251 /* Check if X is a coding system or not. If it is, set ID to the
252 ID of the coding system. */
254 #define CHECK_CODING_SYSTEM_GET_ID(x, id) \
257 id = CODING_SYSTEM_ID (x); \
260 Fcheck_coding_system (x); \
261 id = CODING_SYSTEM_ID (x); \
264 wrong_type_argument (Qcoding_system_p, (x)); \
268 /*** GENERAL section ***/
270 /* Enumeration of result code of code conversion. */
271 enum coding_result_code
273 CODING_RESULT_SUCCESS
,
274 CODING_RESULT_INSUFFICIENT_SRC
,
275 CODING_RESULT_INSUFFICIENT_DST
,
276 CODING_RESULT_INCONSISTENT_EOL
,
277 CODING_RESULT_INVALID_SRC
,
278 CODING_RESULT_INTERRUPT
,
279 CODING_RESULT_INSUFFICIENT_MEM
283 /* Macros used for the member `mode' of the struct coding_system. */
285 /* If set, recover the original CR or LF of the already decoded text
286 when the decoding routine encounters an inconsistent eol format. */
287 #define CODING_MODE_INHIBIT_INCONSISTENT_EOL 0x01
289 /* If set, the decoding/encoding routines treat the current data as
290 the last block of the whole text to be converted, and do the
291 appropriate finishing job. */
292 #define CODING_MODE_LAST_BLOCK 0x02
294 /* If set, it means that the current source text is in a buffer which
295 enables selective display. */
296 #define CODING_MODE_SELECTIVE_DISPLAY 0x04
298 /* This flag is used by the decoding/encoding routines on the fly. If
299 set, it means that right-to-left text is being processed. */
300 #define CODING_MODE_DIRECTION 0x08
302 #define CODING_MODE_FIXED_DESTINATION 0x10
304 /* If set, it means that the encoding routines produces some safe
305 ASCII characters (usually '?') for unsupported characters. */
306 #define CODING_MODE_SAFE_ENCODING 0x20
308 /* For handling composition sequence. */
309 #include "composite.h"
311 enum composition_state
316 COMPOSING_COMPONENT_CHAR
,
317 COMPOSING_COMPONENT_RULE
320 /* Structure for the current composition status. */
321 struct composition_status
323 enum composition_state state
;
324 enum composition_method method
;
325 int old_form
; /* 0:pre-21 form, 1:post-21 form */
326 int length
; /* number of elements produced in charbuf */
327 int nchars
; /* number of characters composed */
328 int ncomps
; /* number of composition components */
329 /* Maximum carryover is for the case of COMPOSITION_WITH_RULE_ALTCHARS.
330 See the comment in coding.c. */
331 int carryover
[4 /* annotation header */
332 + MAX_COMPOSITION_COMPONENTS
* 3 - 2 /* ALTs and RULEs */
333 + 2 /* intermediate -1 -1 */
334 + MAX_COMPOSITION_COMPONENTS
/* CHARs */
339 /* Structure of the field `spec.iso_2022' in the structure
343 /* Bit-wise-or of CODING_ISO_FLAG_XXX. */
346 /* The current graphic register invoked to each graphic plane. */
347 int current_invocation
[2];
349 /* The current charset designated to each graphic register. The
350 value -1 means that not charset is designated, -2 means that
351 there was an invalid designation previously. */
352 int current_designation
[4];
354 /* Set to 1 temporarily only when graphic register 2 or 3 is invoked
355 by single-shift while encoding. */
358 /* Set to 1 temporarily only when processing at beginning of line. */
361 /* If positive, we are now scanning CTEXT extended segment. */
362 int ctext_extended_segment_len
;
364 /* If nonzero, we are now scanning embedded UTF-8 sequence. */
367 /* The current composition. */
368 struct composition_status cmp_status
;
371 struct emacs_mule_spec
374 struct composition_status cmp_status
;
386 enum utf_16_endian_type
394 enum utf_bom_type bom
;
395 enum utf_16_endian_type endian
;
399 struct coding_detection_info
401 /* Values of these members are bitwise-OR of CATEGORY_MASK_XXXs. */
402 /* Which categories are already checked. */
404 /* Which categories are strongly found. */
406 /* Which categories are rejected. */
413 /* ID number of the coding system. This is an index to
414 Vcoding_system_hash_table. This value is set by
415 setup_coding_system. At the early stage of building time, this
416 value is -1 in the array coding_categories to indicate that no
417 coding-system of that category is yet defined. */
420 /* Flag bits of the coding system. The meaning of each bit is common
421 to all types of coding systems. */
424 /* Mode bits of the coding system. See the comments of the macros
428 /* Detailed information specific to each type of coding system. */
431 struct iso_2022_spec iso_2022
;
432 struct ccl_spec
*ccl
; /* Defined in ccl.h. */
433 struct utf_16_spec utf_16
;
434 enum utf_bom_type utf_8_bom
;
435 struct emacs_mule_spec emacs_mule
;
439 unsigned char *safe_charsets
;
441 /* The following two members specify how binary 8-bit code 128..255
442 are represented in source and destination text respectively. 1
443 means they are represented by 2-byte sequence, 0 means they are
444 represented by 1-byte as is (see the comment in character.h). */
445 unsigned src_multibyte
: 1;
446 unsigned dst_multibyte
: 1;
448 /* How may heading bytes we can skip for decoding. This is set to
449 -1 in setup_coding_system, and updated by detect_coding. So,
450 when this is equal to the byte length of the text being
451 converted, we can skip the actual conversion process. */
452 EMACS_INT head_ascii
;
454 /* The following members are set by encoding/decoding routine. */
455 EMACS_INT produced
, produced_char
, consumed
, consumed_char
;
457 /* Number of error source data found in a decoding routine. */
460 /* Store the positions of error source data. */
461 EMACS_INT
*error_positions
;
463 /* Finish status of code conversion. */
464 enum coding_result_code result
;
466 EMACS_INT src_pos
, src_pos_byte
, src_chars
, src_bytes
;
467 Lisp_Object src_object
;
468 const unsigned char *source
;
470 EMACS_INT dst_pos
, dst_pos_byte
, dst_bytes
;
471 Lisp_Object dst_object
;
472 unsigned char *destination
;
474 /* Set to 1 if the source of conversion is not in the member
475 `charbuf', but at `src_object'. */
478 /* If an element is non-negative, it is a character code.
480 If it is in the range -128..-1, it is a 8-bit character code
483 If it is less than -128, it specifies the start of an annotation
484 chunk. The length of the chunk is -128 minus the value of the
485 element. The following elements are OFFSET, ANNOTATION-TYPE, and
486 a sequence of actual data for the annotation. OFFSET is a
487 character position offset from dst_pos or src_pos,
488 ANNOTATION-TYPE specfies the meaning of the annotation and how to
489 handle the following data.. */
491 int charbuf_size
, charbuf_used
;
493 /* Set to 1 if charbuf contains an annotation. */
496 unsigned char carryover
[64];
501 int (*detector
) (struct coding_system
*,
502 struct coding_detection_info
*);
503 void (*decoder
) (struct coding_system
*);
504 int (*encoder
) (struct coding_system
*);
507 /* Meanings of bits in the member `common_flags' of the structure
508 coding_system. The lowest 8 bits are reserved for various kind of
509 annotations (currently two of them are used). */
510 #define CODING_ANNOTATION_MASK 0x00FF
511 #define CODING_ANNOTATE_COMPOSITION_MASK 0x0001
512 #define CODING_ANNOTATE_DIRECTION_MASK 0x0002
513 #define CODING_ANNOTATE_CHARSET_MASK 0x0003
514 #define CODING_FOR_UNIBYTE_MASK 0x0100
515 #define CODING_REQUIRE_FLUSHING_MASK 0x0200
516 #define CODING_REQUIRE_DECODING_MASK 0x0400
517 #define CODING_REQUIRE_ENCODING_MASK 0x0800
518 #define CODING_REQUIRE_DETECTION_MASK 0x1000
519 #define CODING_RESET_AT_BOL_MASK 0x2000
521 /* Return 1 if the coding context CODING requires annotaion
523 #define CODING_REQUIRE_ANNOTATION(coding) \
524 ((coding)->common_flags & CODING_ANNOTATION_MASK)
526 /* Return 1 if the coding context CODING prefers decoding into unibyte. */
527 #define CODING_FOR_UNIBYTE(coding) \
528 ((coding)->common_flags & CODING_FOR_UNIBYTE_MASK)
530 /* Return 1 if the coding context CODING requires specific code to be
531 attached at the tail of converted text. */
532 #define CODING_REQUIRE_FLUSHING(coding) \
533 ((coding)->common_flags & CODING_REQUIRE_FLUSHING_MASK)
535 /* Return 1 if the coding context CODING requires code conversion on
537 #define CODING_REQUIRE_DECODING(coding) \
538 ((coding)->dst_multibyte \
539 || (coding)->common_flags & CODING_REQUIRE_DECODING_MASK)
542 /* Return 1 if the coding context CODING requires code conversion on
544 The non-multibyte part of the condition is to support encoding of
545 unibyte strings/buffers generated by string-as-unibyte or
546 (set-buffer-multibyte nil) from multibyte strings/buffers. */
547 #define CODING_REQUIRE_ENCODING(coding) \
548 ((coding)->src_multibyte \
549 || (coding)->common_flags & CODING_REQUIRE_ENCODING_MASK \
550 || (coding)->mode & CODING_MODE_SELECTIVE_DISPLAY)
553 /* Return 1 if the coding context CODING requires some kind of code
555 #define CODING_REQUIRE_DETECTION(coding) \
556 ((coding)->common_flags & CODING_REQUIRE_DETECTION_MASK)
558 /* Return 1 if the coding context CODING requires code conversion on
559 decoding or some kind of code detection. */
560 #define CODING_MAY_REQUIRE_DECODING(coding) \
561 (CODING_REQUIRE_DECODING (coding) \
562 || CODING_REQUIRE_DETECTION (coding))
564 /* Macros to decode or encode a character of JISX0208 in SJIS. S1 and
565 S2 are the 1st and 2nd position-codes of JISX0208 in SJIS coding
566 system. C1 and C2 are the 1st and 2nd position codes of Emacs'
569 #define SJIS_TO_JIS(code) \
571 int s1, s2, j1, j2; \
573 s1 = (code) >> 8, s2 = (code) & 0xFF; \
576 (j1 = s1 * 2 - (s1 >= 0xE0 ? 0x160 : 0xE0), \
579 (j1 = s1 * 2 - ((s1 >= 0xE0) ? 0x161 : 0xE1), \
580 j2 = s2 - ((s2 >= 0x7F) ? 0x20 : 0x1F)); \
581 (code) = (j1 << 8) | j2; \
584 #define SJIS_TO_JIS2(code) \
586 int s1, s2, j1, j2; \
588 s1 = (code) >> 8, s2 = (code) & 0xFF; \
592 j1 = (s1 == 0xF0 ? 0x28 \
593 : s1 == 0xF1 ? 0x24 \
594 : s1 == 0xF2 ? 0x2C \
595 : s1 == 0xF3 ? 0x2E \
596 : 0x6E + (s1 - 0xF4) * 2); \
601 j1 = (s1 <= 0xF2 ? 0x21 + (s1 - 0xF0) * 2 \
602 : s1 <= 0xF4 ? 0x2D + (s1 - 0xF3) * 2 \
603 : 0x6F + (s1 - 0xF5) * 2); \
604 j2 = s2 - ((s2 >= 0x7F ? 0x20 : 0x1F)); \
606 (code) = (j1 << 8) | j2; \
610 #define JIS_TO_SJIS(code) \
612 int s1, s2, j1, j2; \
614 j1 = (code) >> 8, j2 = (code) & 0xFF; \
616 (s1 = j1 / 2 + ((j1 < 0x5F) ? 0x71 : 0xB1), \
617 s2 = j2 + ((j2 >= 0x60) ? 0x20 : 0x1F)); \
619 (s1 = j1 / 2 + ((j1 < 0x5F) ? 0x70 : 0xB0), \
621 (code) = (s1 << 8) | s2; \
624 #define JIS_TO_SJIS2(code) \
626 int s1, s2, j1, j2; \
628 j1 = (code) >> 8, j2 = (code) & 0xFF; \
631 s1 = (j1 <= 0x25 ? 0xF0 + (j1 - 0x21) / 2 \
632 : j1 <= 0x2F ? 0xF3 + (j1 - 0x2D) / 2 \
633 : 0xF5 + (j1 - 0x6F) / 2); \
634 s2 = j2 + ((j2 >= 0x60) ? 0x20 : 0x1F); \
638 s1 = (j1 == 0x28 ? 0xF0 \
639 : j1 == 0x24 ? 0xF1 \
640 : j1 == 0x2C ? 0xF2 \
641 : j1 == 0x2E ? 0xF3 \
642 : 0xF4 + (j1 - 0x6E) / 2); \
645 (code) = (s1 << 8) | s2; \
648 /* Encode the file name NAME using the specified coding system
649 for file names, if any. */
650 #define ENCODE_FILE(name) \
651 (! NILP (Vfile_name_coding_system) \
652 && !EQ (Vfile_name_coding_system, make_number (0)) \
653 ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \
654 : (! NILP (Vdefault_file_name_coding_system) \
655 && !EQ (Vdefault_file_name_coding_system, make_number (0)) \
656 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \
660 /* Decode the file name NAME using the specified coding system
661 for file names, if any. */
662 #define DECODE_FILE(name) \
663 (! NILP (Vfile_name_coding_system) \
664 && !EQ (Vfile_name_coding_system, make_number (0)) \
665 ? code_convert_string_norecord (name, Vfile_name_coding_system, 0) \
666 : (! NILP (Vdefault_file_name_coding_system) \
667 && !EQ (Vdefault_file_name_coding_system, make_number (0)) \
668 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \
672 /* Encode the string STR using the specified coding system
673 for system functions, if any. */
674 #define ENCODE_SYSTEM(str) \
675 (! NILP (Vlocale_coding_system) \
676 && !EQ (Vlocale_coding_system, make_number (0)) \
677 ? code_convert_string_norecord (str, Vlocale_coding_system, 1) \
680 /* Decode the string STR using the specified coding system
681 for system functions, if any. */
682 #define DECODE_SYSTEM(str) \
683 (! NILP (Vlocale_coding_system) \
684 && !EQ (Vlocale_coding_system, make_number (0)) \
685 ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \
688 /* Note that this encodes utf-8, not utf-8-emacs, so it's not a no-op. */
689 #define ENCODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 1)
691 /* Extern declarations. */
692 extern Lisp_Object
code_conversion_save (int, int);
693 extern int decoding_buffer_size (struct coding_system
*, int);
694 extern int encoding_buffer_size (struct coding_system
*, int);
695 extern void setup_coding_system (Lisp_Object
, struct coding_system
*);
696 extern Lisp_Object
coding_charset_list (struct coding_system
*);
697 extern Lisp_Object
coding_system_charset_list (Lisp_Object
);
698 extern Lisp_Object
code_convert_string (Lisp_Object
, Lisp_Object
,
699 Lisp_Object
, int, int, int);
700 extern Lisp_Object
code_convert_string_norecord (Lisp_Object
, Lisp_Object
,
702 extern Lisp_Object
raw_text_coding_system (Lisp_Object
);
703 extern Lisp_Object
coding_inherit_eol_type (Lisp_Object
, Lisp_Object
);
704 extern Lisp_Object
complement_process_encoding_system (Lisp_Object
);
706 extern int decode_coding_gap (struct coding_system
*,
707 EMACS_INT
, EMACS_INT
);
708 extern void decode_coding_object (struct coding_system
*,
709 Lisp_Object
, EMACS_INT
, EMACS_INT
,
710 EMACS_INT
, EMACS_INT
, Lisp_Object
);
711 extern void encode_coding_object (struct coding_system
*,
712 Lisp_Object
, EMACS_INT
, EMACS_INT
,
713 EMACS_INT
, EMACS_INT
, Lisp_Object
);
715 /* Macros for backward compatibility. */
717 #define decode_coding_region(coding, from, to) \
718 decode_coding_object (coding, Fcurrent_buffer (), \
719 from, CHAR_TO_BYTE (from), \
720 to, CHAR_TO_BYTE (to), Fcurrent_buffer ())
723 #define encode_coding_region(coding, from, to) \
724 encode_coding_object (coding, Fcurrent_buffer (), \
725 from, CHAR_TO_BYTE (from), \
726 to, CHAR_TO_BYTE (to), Fcurrent_buffer ())
729 #define decode_coding_string(coding, string, nocopy) \
730 decode_coding_object (coding, string, 0, 0, SCHARS (string), \
733 #define encode_coding_string(coding, string, nocopy) \
734 (STRING_MULTIBYTE(string) ? \
735 (encode_coding_object (coding, string, 0, 0, SCHARS (string), \
736 SBYTES (string), Qt), \
737 (coding)->dst_object) : (string))
740 #define decode_coding_c_string(coding, src, bytes, dst_object) \
742 (coding)->source = (src); \
743 (coding)->src_chars = (coding)->src_bytes = (bytes); \
744 decode_coding_object ((coding), Qnil, 0, 0, (bytes), (bytes), \
749 extern Lisp_Object
preferred_coding_system (void);
752 extern Lisp_Object Qutf_8
, Qutf_8_emacs
;
754 extern Lisp_Object Qcoding_category_index
;
755 extern Lisp_Object Qcoding_system_p
;
756 extern Lisp_Object Qraw_text
, Qemacs_mule
, Qno_conversion
, Qundecided
;
757 extern Lisp_Object Qbuffer_file_coding_system
;
759 extern Lisp_Object Qunix
, Qdos
, Qmac
;
761 extern Lisp_Object Qtranslation_table
;
762 extern Lisp_Object Qtranslation_table_id
;
765 extern Lisp_Object Qfile_coding_system
;
766 extern Lisp_Object Qcall_process
, Qcall_process_region
;
767 extern Lisp_Object Qstart_process
, Qopen_network_stream
;
768 extern Lisp_Object Qwrite_region
;
770 extern char *emacs_strerror (int);
772 /* Coding system to be used to encode text for terminal display when
773 terminal coding system is nil. */
774 extern struct coding_system safe_terminal_coding
;
778 /* Error signaled when there's a problem with detecting coding system */
779 extern Lisp_Object Qcoding_system_error
;
781 extern char emacs_mule_bytes
[256];
782 extern int emacs_mule_string_char (unsigned char *);
784 #endif /* EMACS_CODING_H */