language-extensions/R/common/src/Unicode.cpp
// -------------------------------------------------------------------------------------------------
// Name: Utf16Size
//
// Description:
//  Returns the number of char16s in the UTF16 representation of the string
//
Utf16Size
Description:
Returns the number of char16s in the UTF16 representation of the string
Utf16Size Description : Returns the number of char16s in the UTF16 representation of the string
size_t Utf16Size(const char *s, size_t l)
{
	size_t ans = 0;
	size_t i = 0;
	while(i < l)
	{
		char32_t char32;
		size_t char8Len;
		bool isIll;
		GetChar32(s + i, l - i, &char32, &char8Len, &isIll);
		if (!isIll)
		{
			ans += GetChar16Len(char32);
		}
		else
		{
			ans += OneChar16Len;
		}
		i += char8Len;
	}
	return ans;
}
size_t Utf16Size ( const char * s , size_t l ) { size_t ans = 0 ; size_t i = 0 ; while ( i < l ) { char32_t char32 ; size_t char8Len ; bool isIll ; GetChar32 ( s + i , l - i , & char32 , & char8Len , & isIll ) ; if ( ! isIll ) { ans += GetChar16Len ( char32 ) ; } else { ans += OneChar16Len ; } i += char8Len ; } return ans ; }
Name: Utf16Size
Description:
Returns the number of char16s in the UTF16 representation of the string
Name : Utf16Size Description : Returns the number of char16s in the UTF16 representation of the string