Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 142 of file ff_unicode.c.
Referenced by FF_FindEntryInDir(), FF_PopulateLongDirent(), and FF_Utf32stoUtf8s().
{ FF_T_UINT32 ulUtf32char; FF_T_UINT16 ulUtf16char; if(!ulSize) { return FF_ERR_UNICODE_DEST_TOO_SMALL; } memcpy(&ulUtf16char, utf16Source, sizeof(FF_T_UINT16)); if((/*bobtntfullfat *utf16Source*/ulUtf16char & 0xF800) == 0xD800) { // A surrogate sequence was encountered. Must transform to UTF32 first. ulUtf32char = ((FF_T_UINT32) (ulUtf16char & 0x003FF) << 10) + 0x10000; //bobtntfullfat ulUtf32char = ((FF_T_UINT32) (*(utf16Source + 0) & 0x003FF) << 10) + 0x10000; memcpy(&ulUtf16char, utf16Source + 1, sizeof(FF_T_UINT16)); if((/*bobtntfullfat *(utf16Source + 1)*/ulUtf16char & 0xFC00) != 0xDC00) { return FF_ERR_UNICODE_INVALID_SEQUENCE; // Invalid UTF-16 sequence. } ulUtf32char |= ((FF_T_UINT32) (/*bobtntfullfat *(utf16Source + 1)*/ulUtf16char & 0x003FF)); } else { ulUtf32char = (FF_T_UINT32) /*bobtntfullfat *utf16Source*/ulUtf16char; } // Now convert to the UTF-8 sequence. if(ulUtf32char < 0x00000080) { // Single byte UTF-8 sequence. *(utf8Dest + 0) = (FF_T_UINT8) ulUtf32char; return 1; } if(ulUtf32char < 0x00000800) { // Double byte UTF-8 sequence. if(ulSize < 2) { return FF_ERR_UNICODE_DEST_TOO_SMALL; } *(utf8Dest + 0) = (FF_T_UINT8) (0xC0 | ((ulUtf32char >> 6) & 0x1F)); *(utf8Dest + 1) = (FF_T_UINT8) (0x80 | ((ulUtf32char >> 0) & 0x3F)); return 2; } if(ulUtf32char < 0x00010000) { // Triple byte UTF-8 sequence. if(ulSize < 3) { return FF_ERR_UNICODE_DEST_TOO_SMALL; } *(utf8Dest + 0) = (FF_T_UINT8) (0xE0 | ((ulUtf32char >> 12) & 0x0F)); *(utf8Dest + 1) = (FF_T_UINT8) (0x80 | ((ulUtf32char >> 6 ) & 0x3F)); *(utf8Dest + 2) = (FF_T_UINT8) (0x80 | ((ulUtf32char >> 0 ) & 0x3F)); return 3; } if(ulUtf32char < 0x00200000) { // Quadruple byte UTF-8 sequence. if(ulSize < 4) { return FF_ERR_UNICODE_DEST_TOO_SMALL; } *(utf8Dest + 0) = (FF_T_UINT8) (0xF0 | ((ulUtf32char >> 18) & 0x07)); *(utf8Dest + 1) = (FF_T_UINT8) (0x80 | ((ulUtf32char >> 12) & 0x3F)); *(utf8Dest + 2) = (FF_T_UINT8) (0x80 | ((ulUtf32char >> 6 ) & 0x3F)); *(utf8Dest + 3) = (FF_T_UINT8) (0x80 | ((ulUtf32char >> 0 ) & 0x3F)); return 4; } return FF_ERR_UNICODE_INVALID_CODE; // Invalid Charachter }