Click here to Skip to main content
11,435,048 members (49,449 online)
Click here to Skip to main content

Tagged as

Unicode/UTF-32: Get Character From Codepoint

, 1 Jan 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
If you ever need to get a character returned from a unicode string (such as "U+2A601") you can use the following method:

This will take care of not only UTF-16, but UTF-32 characters as well.

<pre lang="c#">public static string ConvertUnicodeToCharacter(string unicodeValue)
        {
            int unicode = int.Parse(unicodeValue.Substring(2), NumberStyles.HexNumber);
 
            if (unicodeValue.Length == 7) //UTF-32
            {
                return char.ConvertFromUtf32(unicode);
            }
 
            return ((char)unicode).ToString(); //UTF-16
        }</pre>

Have fun!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

gordon_matt
Software Developer VortexSoft
Vietnam Vietnam
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150428.2 | Last Updated 2 Jan 2011
Article Copyright 2011 by gordon_matt
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid