comparison src/character.c @ 88947:894b8bce3208

(Funibyte_char_to_multibyte): If C can't be decoded by the primary charset, make it eight-bit char. (Fmultibyte_char_to_unibyte): Call CHAR_TO_BYTE8.
author Kenichi Handa <handa@m17n.org>
date Wed, 31 Jul 2002 07:06:36 +0000
parents f026b7e4fc61
children 2d504d707ce6
comparison
equal deleted inserted replaced
88946:233c080b5756 88947:894b8bce3208
245 if (c >= 0400) 245 if (c >= 0400)
246 error ("Invalid unibyte character: %d", c); 246 error ("Invalid unibyte character: %d", c);
247 charset = CHARSET_FROM_ID (charset_primary); 247 charset = CHARSET_FROM_ID (charset_primary);
248 c = DECODE_CHAR (charset, c); 248 c = DECODE_CHAR (charset, c);
249 if (c < 0) 249 if (c < 0)
250 error ("Can't convert to multibyte character: %d", XINT (ch)); 250 c = BYTE8_TO_CHAR (XFASTINT (ch));
251 return make_number (c); 251 return make_number (c);
252 } 252 }
253 253
254 DEFUN ("multibyte-char-to-unibyte", Fmultibyte_char_to_unibyte, 254 DEFUN ("multibyte-char-to-unibyte", Fmultibyte_char_to_unibyte,
255 Smultibyte_char_to_unibyte, 1, 1, 0, 255 Smultibyte_char_to_unibyte, 1, 1, 0,
258 the current primary charset (value of `charset-primary'). */) 258 the current primary charset (value of `charset-primary'). */)
259 (ch) 259 (ch)
260 Lisp_Object ch; 260 Lisp_Object ch;
261 { 261 {
262 int c; 262 int c;
263 unsigned code;
264 struct charset *charset; 263 struct charset *charset;
265 264
266 CHECK_CHARACTER (ch); 265 CHECK_CHARACTER (ch);
267 c = XFASTINT (ch); 266 c = XFASTINT (ch);
268 charset = CHARSET_FROM_ID (charset_primary); 267 c = CHAR_TO_BYTE8 (c);
269 code = ENCODE_CHAR (charset, c); 268 return make_number (c);
270 if (code < CHARSET_MIN_CODE (charset)
271 || code > CHARSET_MAX_CODE (charset))
272 error ("Can't convert to unibyte character: %d", XINT (ch));
273 return make_number (code);
274 } 269 }
275 270
276 DEFUN ("char-bytes", Fchar_bytes, Schar_bytes, 1, 1, 0, 271 DEFUN ("char-bytes", Fchar_bytes, Schar_bytes, 1, 1, 0,
277 doc: /* Return 1 regardless of the argument CHAR. 272 doc: /* Return 1 regardless of the argument CHAR.
278 This is now an obsolete function. We keep it just for backward compatibility. */) 273 This is now an obsolete function. We keep it just for backward compatibility. */)