summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1998-08-18 11:02:54 +0000
committerRichard M. Stallman <rms@gnu.org>1998-08-18 11:02:54 +0000
commitf35f81a499de06bf4bb5c576775224cf7901a21a (patch)
tree13d1e86450d48d2099a02551ed51736703a74093
parenta8ca112ae32478607c164d7451c852cb841c3ae5 (diff)
downloademacs-f35f81a499de06bf4bb5c576775224cf7901a21a.tar.gz
(Fmultibyte_char_to_unibyte): New function.
(syms_of_charset): defsubr it.
-rw-r--r--src/charset.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/charset.c b/src/charset.c
index e43492a67ae..819045842b5 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -994,6 +994,26 @@ The conversion is done based on `nonascii-translation-table' (which see)\n\
return make_number (c);
}
+DEFUN ("multibyte-char-to-unibyte", Fmultibyte_char_to_unibyte,
+ Smultibyte_char_to_unibyte, 1, 1, 0,
+ "Convert the multibyte character CH to unibyte character.\n\
+The conversion is done based on `nonascii-translation-table' (which see)\n\
+ or `nonascii-insert-offset' (which see).")
+ (ch)
+ Lisp_Object ch;
+{
+ int c;
+
+ CHECK_NUMBER (ch, 0);
+ c = XINT (ch);
+ if (c < 0)
+ error ("Invalid multibyte character: %d", c);
+ c = multibyte_char_to_unibyte (c, Qnil);
+ if (c < 0)
+ error ("Can't convert to unibyte character: %d", XINT (ch));
+ return make_number (c);
+}
+
DEFUN ("char-bytes", Fchar_bytes, Schar_bytes, 1, 1, 0,
"Return byte length of multi-byte form of CHAR.")
(ch)
@@ -1819,6 +1839,7 @@ syms_of_charset ()
defsubr (&Siso_charset);
defsubr (&Schar_valid_p);
defsubr (&Sunibyte_char_to_multibyte);
+ defsubr (&Smultibyte_char_to_unibyte);
defsubr (&Schar_bytes);
defsubr (&Schar_width);
defsubr (&Sstring_width);