From: Kenichi Handa Date: Wed, 31 Jul 2002 07:11:47 +0000 (+0000) Subject: (Fstring_to_multibyte): New function. X-Git-Tag: emacs-pretest-23.0.90~8295^2~1864^2~478 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=88dad6e7cba24726c9cd5b1c247510ff27351ab9;p=emacs.git (Fstring_to_multibyte): New function. (syms_of_fns): Declare Fstring_to_multibyte as Lisp subroutine. --- diff --git a/src/fns.c b/src/fns.c index 9f2837943ad..0a1ce7d26da 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1055,6 +1055,40 @@ multibyte character of charset `eight-bit-control' or `eight-bit-graphic'. */) } return string; } + + +DEFUN ("string-to-multibyte", Fstring_to_multibyte, Sstring_to_multibyte, + 1, 1, 0, + doc: /* Return a multibyte string with the same individual chars as STRING. +If STRING is multibyte, the result is STRING itself. +Otherwise it is a newly created string, with no text properties. + +If STRING is unibyte and contains an 8-bit byte, it is converted to +the corresponding multibyte character of charset `eight-bit'. */) + (string) + Lisp_Object string; +{ + CHECK_STRING (string); + + if (! STRING_MULTIBYTE (string)) + { + Lisp_Object new_string; + int nchars, nbytes; + + nchars = XSTRING (string)->size; + nbytes = parse_str_to_multibyte (XSTRING (string)->data, + STRING_BYTES (XSTRING (string))); + new_string = make_uninit_multibyte_string (nchars, nbytes); + bcopy (XSTRING (string)->data, XSTRING (new_string)->data, + STRING_BYTES (XSTRING (string))); + if (nbytes != STRING_BYTES (XSTRING (string))) + str_to_multibyte (XSTRING (new_string)->data, nbytes, + STRING_BYTES (XSTRING (string))); + string = new_string; + XSTRING (string)->intervals = NULL_INTERVAL; + } + return string; +} DEFUN ("copy-alist", Fcopy_alist, Scopy_alist, 1, 1, 0, doc: /* Return a copy of ALIST. @@ -4898,6 +4932,7 @@ invoked by mouse clicks and mouse menu items. */); defsubr (&Sstring_make_unibyte); defsubr (&Sstring_as_multibyte); defsubr (&Sstring_as_unibyte); + defsubr (&Sstring_to_multibyte); defsubr (&Scopy_alist); defsubr (&Ssubstring); defsubr (&Snthcdr);