Function
utf16_encode
Encode to UTF-16 (native byte order).
Since v1.0
int32_t utf16_encode(
uchar c,
uint16_t *buf)
Parameters 🔗
| c | in | Unicode scalar value. |
| buf | out | Destination buffer for the encoded |
Return Value 🔗
Returns the number of code units written to buf on success. Returns a negative integer if c is not a valid Unicode scalar value.
Discussion 🔗
Encodes the Unicode scalar value c as UTF-16 code unit(s) and writes them to buf. The length of buf must be at least two code units.
If c is not a valid Unicode scalar value, buf remains unchanged and a negative integer is returned.