comparison src/mule-coding.h @ 215:1f0dabaa0855 r20-4b6

Import from CVS: tag r20-4b6
author cvs
date Mon, 13 Aug 2007 10:07:35 +0200
parents 78f53ef88e17
children 83b3d10dcba9
comparison
equal deleted inserted replaced
214:c5d88c05e1e9 215:1f0dabaa0855
406 #define CODING_CATEGORY_NO_CONVERSION_MASK \ 406 #define CODING_CATEGORY_NO_CONVERSION_MASK \
407 (1 << CODING_CATEGORY_NO_CONVERSION) 407 (1 << CODING_CATEGORY_NO_CONVERSION)
408 #define CODING_CATEGORY_NOT_FINISHED_MASK \ 408 #define CODING_CATEGORY_NOT_FINISHED_MASK \
409 (1 << 30) 409 (1 << 30)
410 410
411 /* Macros to decode or encode a character of JISX0208 in SJIS. S1 and 411 /* Convert shift-JIS code (sj1, sj2) into internal string
412 S2 are the 1st and 2nd position-codes of JISX0208 in SJIS coding 412 representation (c1, c2). (The leading byte is assumed.) */
413 system. C1 and C2 are the 1st and 2nd position codes of Emacs' 413
414 internal format. */ 414 #define DECODE_SJIS(sj1, sj2, c1, c2) \
415 415 do { \
416 #define DECODE_SJIS(s1, s2, c1, c2) \ 416 int I1 = sj1, I2 = sj2; \
417 do { \ 417 if (I2 >= 0x9f) \
418 if (s2 >= 0x9F) \ 418 c1 = (I1 << 1) - ((I1 >= 0xe0) ? 0xe0 : 0x60), \
419 c1 = s1 * 2 - (s1 >= 0xE0 ? 0x160 : 0xE0), \ 419 c2 = I2 + 2; \
420 c2 = s2 - 0x7E; \ 420 else \
421 else \ 421 c1 = (I1 << 1) - ((I1 >= 0xe0) ? 0xe1 : 0x61), \
422 c1 = s1 * 2 - ((s1 >= 0xE0) ? 0x161 : 0xE1), \ 422 c2 = I2 + ((I2 >= 0x7f) ? 0x60 : 0x61); \
423 c2 = s2 - ((s2 >= 0x7F) ? 0x20 : 0x1F); \ 423 } while (0)
424 } while (0) 424
425 425 /* Convert the internal string representation of a Shift-JIS character
426 #define ENCODE_SJIS(c1, c2, s1, s2) \ 426 (c1, c2) into Shift-JIS code (sj1, sj2). The leading byte is
427 do { \ 427 assumed. */
428 if ((c1) & 1) \ 428
429 s1 = (c1) / 2 + (((c1) < 0x5F) ? 0x71 : 0xB1), \ 429 #define ENCODE_SJIS(c1, c2, sj1, sj2) \
430 s2 = (c2) + (((c2) >= 0x60) ? 0x20 : 0x1F); \ 430 do { \
431 else \ 431 int I1 = c1, I2 = c2; \
432 s1 = (c1) / 2 + (((c1) < 0x5F) ? 0x70 : 0xB0), \ 432 if (I1 & 1) \
433 s2 = (c2) + 0x7E; \ 433 sj1 = (I1 >> 1) + ((I1 < 0xdf) ? 0x31 : 0x71), \
434 } while (0) 434 sj2 = I2 - ((I2 >= 0xe0) ? 0x60 : 0x61); \
435 435 else \
436 sj1 = (I1 >> 1) + ((I1 < 0xdf) ? 0x30 : 0x70), \
437 sj2 = I2 - 2; \
438 } while (0)
436 439
437 extern Lisp_Object make_decoding_input_stream (Lstream *stream, 440 extern Lisp_Object make_decoding_input_stream (Lstream *stream,
438 Lisp_Object codesys); 441 Lisp_Object codesys);
439 extern Lisp_Object make_encoding_input_stream (Lstream *stream, 442 extern Lisp_Object make_encoding_input_stream (Lstream *stream,
440 Lisp_Object codesys); 443 Lisp_Object codesys);