aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2002-09-03 04:07:11 +0000
committerKenichi Handa2002-09-03 04:07:11 +0000
commitb672c5ae184600f484a0af3cb7079a148c9fab70 (patch)
tree60a6d586d20055ea61fa056efbeee207ff153782 /src
parent43c4748349284a134b17c92077a14db81b92166b (diff)
downloademacs-b672c5ae184600f484a0af3cb7079a148c9fab70.tar.gz
emacs-b672c5ae184600f484a0af3cb7079a148c9fab70.zip
(unibyte_to_multibyte_table): New variable.
(unibyte_char_to_multibyte): Move to character.h and defined as macro. (multibyte_char_to_unibyte): If C is an eight-bit character, convert it to the corresponding byte value.
Diffstat (limited to 'src')
-rw-r--r--src/character.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/character.c b/src/character.c
index 6f84fb4ccc3..2031e5e9b36 100644
--- a/src/character.c
+++ b/src/character.c
@@ -81,6 +81,8 @@ Lisp_Object Vchar_script_table;
81 81
82static Lisp_Object Qchar_script_table; 82static Lisp_Object Qchar_script_table;
83 83
84/* Mapping table from unibyte chars to multibyte chars. */
85int unibyte_to_multibyte_table[256];
84 86
85 87
86 88
@@ -179,21 +181,6 @@ translate_char (table, c)
179 return XINT (ch); 181 return XINT (ch);
180} 182}
181 183
182/* Convert the unibyte character C to the corresponding multibyte
183 character based on the current value of charset_unibyte. If C
184 can't be converted, return C. */
185
186int
187unibyte_char_to_multibyte (c)
188 int c;
189{
190 struct charset *charset = CHARSET_FROM_ID (charset_unibyte);
191 int c1 = DECODE_CHAR (charset, c);
192
193 return ((c1 >= 0) ? c1 : c);
194}
195
196
197/* Convert the multibyte character C to unibyte 8-bit character based 184/* Convert the multibyte character C to unibyte 8-bit character based
198 on the current value of charset_unibyte. If dimension of 185 on the current value of charset_unibyte. If dimension of
199 charset_unibyte is more than one, return (C & 0xFF). 186 charset_unibyte is more than one, return (C & 0xFF).
@@ -206,9 +193,13 @@ multibyte_char_to_unibyte (c, rev_tbl)
206 int c; 193 int c;
207 Lisp_Object rev_tbl; 194 Lisp_Object rev_tbl;
208{ 195{
209 struct charset *charset = CHARSET_FROM_ID (charset_unibyte); 196 struct charset *charset;
210 unsigned c1 = ENCODE_CHAR (charset, c); 197 unsigned c1;
211 198
199 if (CHAR_BYTE8_P (c))
200 return CHAR_TO_BYTE8 (c);
201 charset = CHARSET_FROM_ID (charset_unibyte);
202 c1 = ENCODE_CHAR (charset, c);
212 return ((c1 != CHARSET_INVALID_CODE (charset)) ? c1 : c & 0xFF); 203 return ((c1 != CHARSET_INVALID_CODE (charset)) ? c1 : c & 0xFF);
213} 204}
214 205