diff options
| author | Kenichi Handa | 2007-02-15 11:27:15 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2007-02-15 11:27:15 +0000 |
| commit | 935d5b020cd919203ea7e7cef21af09447aaad26 (patch) | |
| tree | a52eea17f61bf6f9fcabd3296fa083ae4db4a592 /src | |
| parent | 89ad649268900b3137a01d6c888f8a156f2cf792 (diff) | |
| download | emacs-935d5b020cd919203ea7e7cef21af09447aaad26.tar.gz emacs-935d5b020cd919203ea7e7cef21af09447aaad26.zip | |
(multibyte_char_to_unibyte_safe): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/character.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/character.c b/src/character.c index 3d3e28bc7d2..29a7f80ae49 100644 --- a/src/character.c +++ b/src/character.c | |||
| @@ -275,6 +275,22 @@ multibyte_char_to_unibyte (c, rev_tbl) | |||
| 275 | return ((c1 != CHARSET_INVALID_CODE (charset)) ? c1 : c & 0xFF); | 275 | return ((c1 != CHARSET_INVALID_CODE (charset)) ? c1 : c & 0xFF); |
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | /* Like multibyte_char_to_unibyte, but return -1 if C is not supported | ||
| 279 | by charset_unibyte. */ | ||
| 280 | |||
| 281 | int | ||
| 282 | multibyte_char_to_unibyte_safe (c) | ||
| 283 | int c; | ||
| 284 | { | ||
| 285 | struct charset *charset; | ||
| 286 | unsigned c1; | ||
| 287 | |||
| 288 | if (CHAR_BYTE8_P (c)) | ||
| 289 | return CHAR_TO_BYTE8 (c); | ||
| 290 | charset = CHARSET_FROM_ID (charset_unibyte); | ||
| 291 | c1 = ENCODE_CHAR (charset, c); | ||
| 292 | return ((c1 != CHARSET_INVALID_CODE (charset)) ? c1 : -1); | ||
| 293 | } | ||
| 278 | 294 | ||
| 279 | DEFUN ("characterp", Fcharacterp, Scharacterp, 1, 2, 0, | 295 | DEFUN ("characterp", Fcharacterp, Scharacterp, 1, 2, 0, |
| 280 | doc: /* Return non-nil if OBJECT is a character. */) | 296 | doc: /* Return non-nil if OBJECT is a character. */) |