I have this UI that needs unicode values to display superscript Characters. the data is coming inbound has html code.The only problem I can see is that it needs an extra backslash. I am passing a string of "®" into EncodeNonAsciiCharacters.
Is there any way to return
\u00AEand not\\u00AE
static string EncodeNonAsciiCharacters(string value)
{
StringBuilder sb = new StringBuilder();
foreach (char c in value)
{
if (c > 127)
{
string encodedtext = ((int)c).ToString("x4");
//string encodedValue = "\\u" + encodedtext.ToUpper();
string encodedValue = @"\u" + encodedtext.ToUpper();
sb.Append(encodedValue);
}
else
{
sb.Append(c);
}
}
return sb.ToString();
}
strings UTF-16 already?\\u00AE. You need to write\\uin your code editor because\is an escape character in C# string literals. You could write@"\u"instead if you wanted.