language-extensions/R/common/src/Unicode.cpp
// -------------------------------------------------------------------------------------------------
// Name: ToUtf8
//
// Description:
//  Converts the given char16_t to an utf-8 encoded string
//
ToUtf8
Description:
Converts the given char16_t to an utf-8 encoded string
ToUtf8 Description : Converts the given char16_t to an utf - 8 encoded string
void ToUtf8(const char16_t *s, size_t len, std::string &ans, bool throwOnError)
{
	ans.resize(Utf8Size(s, len));
	size_t i = 0;
	size_t j = 0;
	while (i < len)
	{
		char32_t char32;
		size_t char16Len;
		GetChar32(s+i, len-i, &char32, &char16Len, throwOnError);
		i += char16Len;
		size_t char8Len;
		GetChar8(char32, &ans[j], &char8Len);
		j += char8Len;
	}
}
void ToUtf8 ( const char16_t * s , size_t len , std :: string & ans , bool throwOnError ) { ans . resize ( Utf8Size ( s , len ) ) ; size_t i = 0 ; size_t j = 0 ; while ( i < len ) { char32_t char32 ; size_t char16Len ; GetChar32 ( s + i , len - i , & char32 , & char16Len , throwOnError ) ; i += char16Len ; size_t char8Len ; GetChar8 ( char32 , & ans [ j ] , & char8Len ) ; j += char8Len ; } }
Name: ToUtf8
Description:
Converts the given char16_t to an utf-8 encoded string
Name : ToUtf8 Description : Converts the given char16_t to an utf - 8 encoded string