pub unsafe fn encode_utf8(
    ch: char,
    ptr: *mut u8,
    len: usize,
) -> Result<usize, EncodeUtf8Error>Expand description
Encode a char into buf using UTF-8.
On success, return the byte length of the encoding (1, 2, 3 or 4).
On error, return EncodeUtf8Error if the buffer was too short for the char.
Safety: ptr must be writable for len bytes.