#[doc(hidden)] pub const unsafe fn encode_utf8_raw_unchecked(
code: u32,
dst: *mut u8,
)
🔬This is a nightly-only experimental API. (
char_internals
)Expand description
Encodes a raw u32
value as UTF-8 into the byte buffer pointed to by dst
.
Unlike char::encode_utf8
, this method also handles codepoints in the surrogate range.
(Creating a char
in the surrogate range is UB.)
The result is valid generalized UTF-8 but not valid UTF-8.
§Safety
The behavior is undefined if the buffer pointed to by dst
is not
large enough to hold the encoded codepoint. A buffer of length four
is large enough to encode any char
.
For a safe version of this function, see the encode_utf8_raw
function.