Function std::utf8_encode
int utf8_encode(unsigned int cp, &char out)Encodes 'cp' into 'out' (caller-provided buffer, must have room for at least 4 bytes — UTF-8's longest encoding). Returns the number of bytes written (1-4), or 0 if 'cp' is not a valid Unicode scalar value (> 0x10FFFF or inside the surrogate range 0xD800..0xDFFF).