Wide character to UTF-16.
|s ||where to store the converted UTF-16 character; |
|wc ||the wide character to convert; |
|size ||max number of uint16_t units to store in |
- Return values:
|>0 ||the length in uint16_t units of the converted UTF-16 character, stored in |
|-EINVAL ||invalid wide character (don't know how to convert it to UTF-16); |
size too small to store the UTF-16 character.
Definition at line 98 of file utf16le.c.
if (wc >= 0)
if (wc < 0x010000)
*s = little_endian_16((uint16_t) wc);
if (wc < 0x200000)
*s = little_endian_16((uint16_t) (0xD800 + (((wc >> 16) - 1) << 6) + ((wc & 0x00FC00) >> 2)));
*(s + 1) = little_endian_16((uint16_t) (0xDC00 + (wc & 0x0003FF)));