Showing posts with label String. Show all posts
Showing posts with label String. Show all posts

Tuesday, July 19, 2011

Convert UTF-8 to Unicode extension

The code:

public static string UTF8ToUnicode(this string input)

{

    return Encoding.Unicode.GetString(

                        Encoding.Convert(Encoding.UTF8,

                                            Encoding.Unicode,  

                                            Encoding.UTF8.GetBytes(

                                                        input)));

}

 

Example:

 

string txt ="Hello, World!";

txt.UTF8ToUnicode();