language-extensions/R/common/src/Unicode.cpp
// -------------------------------------------------------------------------------------------------
// Name: GetChar16
//
// Description:
//  Converts a UTF32 character to UTF16 and return the number of char16_t units in len.
//
GetChar16
Description:
Converts a UTF32 character to UTF16 and return the number of char16_t units in len.
GetChar16 Description : Converts a UTF32 character to UTF16 and return the number of char16_t units in len .
static inline void
GetChar16(char32_t char32, char16_t *char16, size_t *len)
{
	if (char32 <= 0xdf77 || (char32 >= 0xe000 && char32 <= 0xffff))
	{
		*char16 = static_cast<char16_t>(char32);
		*len = OneChar16Len;
	}
	else if (char32 >= 0x10000 && char32 <= 0x10ffff)
	{
		char32 -= 0x10000;
		*char16 = static_cast<char16_t>(0xd800 + (char32 >> 10));
		*(char16 + 1) = static_cast<char16_t>(0xdc00 + (char32 & 0x0000003ff));
		*len = TwoChar16Len;
	}
	else
	{
		*char16 = BadChar;
		*len = OneChar16Len;
	}
}
static inline void GetChar16 ( char32_t char32 , char16_t * char16 , size_t * len ) { if ( char32 <= 0xdf77 || ( char32 >= 0xe000 && char32 <= 0xffff ) ) { * char16 = static_cast < char16_t > ( char32 ) ; * len = OneChar16Len ; } else if ( char32 >= 0x10000 && char32 <= 0x10ffff ) { char32 -= 0x10000 ; * char16 = static_cast < char16_t > ( 0xd800 + ( char32 >> 10 ) ) ; * ( char16 + 1 ) = static_cast < char16_t > ( 0xdc00 + ( char32 & 0x0000003ff ) ) ; * len = TwoChar16Len ; } else { * char16 = BadChar ; * len = OneChar16Len ; } }
Name: GetChar16
Description:
Converts a UTF32 character to UTF16 and return the number of char16_t units in len.
Name : GetChar16 Description : Converts a UTF32 character to UTF16 and return the number of char16_t units in len .