tags:

views:

529

answers:

4

Hi!

I'm working with C# .Net

I would like to know how to convert a Unicode form string like "\u1D0EC" (note that it's above "\uFFFF") to it's symbol... ""

Thanks For Advance!!!

+4  A: 

That Unicode codepoint is encoded in UTF32. .NET and Windows encode Unicode in UTF16, you'll have to translate. UTF16 uses "surrogate pairs" to handle codepoints above 0xffff, a similar kind of approach as UTF8. The first code of the pair is 0xd800..dbff, the second code is 0xdc00..dfff. Try this sample code to see that at work:

using System;
using System.Text;

class Program {
  static void Main(string[] args) {
    uint utf32 = uint.Parse("1D0EC", System.Globalization.NumberStyles.HexNumber);
    string s = Encoding.UTF32.GetString(BitConverter.GetBytes(utf32));
    foreach (char c in s.ToCharArray()) {
      Console.WriteLine("{0:X}", (uint)c);
    }
    Console.ReadLine();
  }
}
Hans Passant
thanks - Great!!! helped a lot!
Jack
+1  A: 

Convert each sequence with int.Parse(String, NumberStyles) and char.ConvertFromUtf32:

string s = @"\U1D0EC";
string converted = char.ConvertFromUtf32(int.Parse(s.Substring(2), NumberStyles.HexNumber));
bruno conde
thanks!!! very very much!
Jack
A: 

Hi jack I have recently push my FOSS Uncode Converter at Codeplex (http://uniode.codeplex.com)

you can convert whatever you want to Hex code and from Hex code to get the right character, also there is a full information character database.

I use this code

public static char ConvertHexToUnicode(string hexCode)
    {
        if (hexCode != string.Empty)
            return ((char)int.Parse(hexCode, NumberStyles.AllowHexSpecifier));

        char empty = new char();
        return empty;
    }//end

you can see entire code on the unicde.codeplex.com

Nasser Hadjloo
A: 

It appears you just want this in your code... you can type it as a string literal using the escape code \Uxxxxxxxx (note that this is a capital U, and there must be 8 digits). For this example, it would be: "\U0001D0EC".

Porges