/* Return value: Number of elements in the utf16 string or 0 if an invalid unicode character  */
int _cairo_ucs4_to_utf16(uint32_t unicode, uint16_t *utf16)
/* Return value: Number of elements in the utf16 string or 0 if an invalid unicode character  */
int _cairo_ucs4_to_utf16(uint32_t unicode, uint16_t *utf16)
{
    if (unicode < 0x10000) {
	if (utf16)
	    utf16[0] = unicode;
	return 1;
    } else if (unicode < 0x110000) {
	if (utf16) {
	    utf16[0] = (unicode - 0x10000) / 0x400 + 0xd800;
	    utf16[1] = (unicode - 0x10000) % 0x400 + 0xdc00;
	}
	return 2;
    } else {
	return 0;
    }
}