Mercurial > emacs
comparison src/insdel.c @ 22876:8c063663a19d
(copy_text): In multibyte to unibyte conversion, take
nonascii-translation-table and nonascii-insert-offset into
account.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Sun, 02 Aug 1998 01:06:57 +0000 |
parents | 5507c26908af |
children | 6d368c9a689e |
comparison
equal
deleted
inserted
replaced
22875:b33307c77a17 | 22876:8c063663a19d |
---|---|
697 } | 697 } |
698 else if (from_multibyte) | 698 else if (from_multibyte) |
699 { | 699 { |
700 int nchars = 0; | 700 int nchars = 0; |
701 int bytes_left = nbytes; | 701 int bytes_left = nbytes; |
702 Lisp_Object tbl = Qnil, temp; | |
703 | |
704 /* We set the variable tbl to the reverse table of | |
705 Vnonascii_translation_table in advance. */ | |
706 if (CHAR_TABLE_P (Vnonascii_translation_table)) | |
707 { | |
708 tbl = Fchar_table_extra_slot (Vnonascii_translation_table, | |
709 make_number (0)); | |
710 if (!CHAR_TABLE_P (tbl)) | |
711 tbl = Qnil; | |
712 } | |
702 | 713 |
703 /* Convert multibyte to single byte. */ | 714 /* Convert multibyte to single byte. */ |
704 while (bytes_left > 0) | 715 while (bytes_left > 0) |
705 { | 716 { |
706 int thislen, c; | 717 int thislen, c, c_save; |
707 c = STRING_CHAR_AND_LENGTH (from_addr, bytes_left, thislen); | 718 c = c_save = STRING_CHAR_AND_LENGTH (from_addr, bytes_left, thislen); |
708 *to_addr++ = SINGLE_BYTE_CHAR_P (c) ? c : (c & 0177) + 0200; | 719 if (!SINGLE_BYTE_CHAR_P (c)) |
720 { | |
721 if (!NILP (tbl)) | |
722 { | |
723 temp = Faref (tbl, make_number (c)); | |
724 if (INTEGERP (temp)) | |
725 c = XINT (temp); | |
726 } | |
727 else if (nonascii_insert_offset > 0) | |
728 c -= nonascii_insert_offset; | |
729 if (c < 128 || c >= 256) | |
730 c = (c_save & 0177) + 0200; | |
731 } | |
732 *to_addr++ = c; | |
709 from_addr += thislen; | 733 from_addr += thislen; |
710 bytes_left -= thislen; | 734 bytes_left -= thislen; |
711 nchars++; | 735 nchars++; |
712 } | 736 } |
713 return nchars; | 737 return nchars; |