I want to convert unicode string to UTF8 string. I want to use this UTF8 string in SMS API to send unicode SMS. I want conversion like this tool https://cafewebmaster.com/online_tools/utf8_encode
eg. I have unicode string "हैलो फ़्रेंड्स" and it should be converted into "हà¥à¤²à¥ à¥à¥à¤°à¥à¤à¤¡à¥à¤¸"
I have tried this but not getting expected output
private string UnicodeToUTF8(string strFrom)
{
byte[] bytes = Encoding.Default.GetBytes(strFrom);
return Encoding.UTF8.GetString(bytes);
}
and calling function like this
string myUTF8String = UnicodeToUTF8("हैलो फ़्रेंड्स");
ASCIIis notutf-8on the best of daysEncoding.DefaultwithEncoding.UTF8and then use the resultingbyte[]array as-is, don't pass it back toGetString()at all. Which SMS API are you using exactly? If it supports Unicode properly, it should be taking a Unicode string as input and handle the UTF-8 encoding internally for you