Append Unicode characters to String

csharp , unicode , string Tel Aviv-Yafo, Israel
  • 8 years ago
    Hello all, I have a string of 4 Unicode chars in the format: U+9ffU+5a01U+6c7dU+8eca. U+ : represents the beggining of the char series. I need to get the .Net string, in this case we want to get 4 Chinese letters: 駿威汽車 There is "the normal way" to use otomatic parsing of string: string st = "\u99ff\u5a01\u6c7d\u8eca"; (and we get st = 駿威汽車) but it is good just for copiler time and not for run time. and the next code also don't work string st = "U+99ffU+5a01U+6c7dU+8eca"; st = st.Replace("U+", @"\u"); string st1 = st; Any Ideas'?
  • 8 years ago
    Hi - welcome to developerFusion! You should be able to do something like this: StringBuilder sb = new StringBuilder(); int characterCode = Convert.ToInt32("99ff", 16); // convert from Hex to standard int sb.Append((char)code); // append this character Debug.WriteLine(sb); Hope that helps
  • 8 years ago
    Thanks James, It will work, Regards

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“God could create the world in six days because he didn't have to make it compatible with the previous version.”