Logo Search packages:      
Sourcecode: fuse-umfuse-fat version File versions  Download package

int unicode_wchar_to_utf16le ( uint16_t *  s,
wchar_t  wc,
size_t  size 
)

Wide character to UTF-16.

Parameters:
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 s;
Return values:
>0 the length in uint16_t units of the converted UTF-16 character, stored in s;
-EINVAL invalid wide character (don't know how to convert it to UTF-16);
-ENAMETOOLONG size too small to store the UTF-16 character.
Remarks:
This is the little endian version of unicode_wchar_to_utf16be()

Definition at line 98 of file utf16le.c.

{
      if (wc >= 0)
      {
            if (wc < 0x010000)
            {
                  *s = little_endian_16((uint16_t) wc);
                  return 1;
            }
            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)));
                  return 2;
            }
      }
      return -EINVAL;
}


Generated by  Doxygen 1.6.0   Back to index