Function: string-make-multibyte
string-make-multibyte is a function defined in fns.c.
This function is obsolete since 26.1; use decode-coding-string.
Signature
(string-make-multibyte STRING)
Documentation
Return the multibyte equivalent of STRING.
If STRING is unibyte and contains non-ASCII characters, the function
unibyte-char-to-multibyte is used to convert each unibyte character
to a multibyte character. In this case, the returned string is a
newly created string with no text properties. If STRING is multibyte
or entirely ASCII, it is returned unchanged. In particular, when
STRING is unibyte and entirely ASCII, the returned string is unibyte.
(When the characters are all ASCII, Emacs primitives will treat the
string the same way whether it is unibyte or multibyte.)
Probably introduced at or before Emacs version 20.3.
Source Code
// Defined in /usr/src/emacs/src/fns.c
{
CHECK_STRING (string);
if (STRING_MULTIBYTE (string))
return string;
ptrdiff_t nchars = SCHARS (string);
ptrdiff_t nbytes = count_size_as_multibyte (SDATA (string), nchars);
if (nbytes == nchars)
return string;
Lisp_Object ret = make_uninit_multibyte_string (nchars, nbytes);
str_to_multibyte (SDATA (ret), SDATA (string), nchars);
return ret;
}