Function: string-to-unibyte
string-to-unibyte is a function defined in fns.c.
Signature
(string-to-unibyte STRING)
Documentation
Return a unibyte string with the same individual chars as STRING.
If STRING is unibyte, the result is STRING itself.
Otherwise it is a newly created string, with no text properties,
where each eight-bit character is converted to the corresponding byte.
If STRING contains a non-ASCII, non-eight-bit character,
an error is signaled.
Probably introduced at or before Emacs version 23.1.
Source Code
// Defined in /usr/src/emacs/src/fns.c
{
CHECK_STRING (string);
if (STRING_MULTIBYTE (string))
{
ptrdiff_t chars = SCHARS (string);
unsigned char *str = xmalloc (chars);
ptrdiff_t converted = str_to_unibyte (SDATA (string), str, chars);
if (converted < chars)
error ("Can't convert the %"pD"dth character to unibyte", converted);
string = make_unibyte_string ((char *) str, chars);
xfree (str);
}
return string;
}