I know following is the way to use unicode in C#
string unicodeString = "\u0D15";
In my situation, I will not get the character code (0D15) at compile time. I get this from a XML file at runtime. I wonder how do I convert this code to unicode string? I tried the following
// will not compile as unrecognized escape sequence
string unicodeString = "\u" + codeFromXML;
// will compile, but just concatenates u with the string got from XML file.
string unicodeString = "\\u" + codeFromXML;
How do I handle this situation?
Any help would be great!
You want to use the char.ConvertFromUtf32 function.
string codePoint = "0D15";
int code = int.Parse(codePoint, System.Globalization.NumberStyles.HexNumber);
string unicodeString = char.ConvertFromUtf32(code);
// unicodeString = "ക"