Click here to Skip to main content
13,006,730 members (62,422 online)
Click here to Skip to main content
Add your own
alternative version


14 bookmarked
Posted 31 Dec 2010

A viewer of the Unicode character set

, 2 Jan 2011
Rate this:
Please Sign up or sign in to vote.
Everybody knows the ASCII table, but what about the Unicode table? View it at last with this small program.



Since the 80's we were familiar with the ASCII code, and know that the symbol for letter A is associated with ASCII code 65, the symbol for letter B is associated with ASCII code 66, and so on till 127 (contrarily to what is sometimes written, the ASCII code stops at 127 and not at 255). But the strings in .NET are not coded in ASCII, but in 16 bits Unicode. This means that you have access (in theory) to 65536 different symbols. This program shows how to display any Unicode character and the associated value.

Using the code

Just specify the range of codes you want to see and the number of displayed characters per line, and press the "Generate" button.

  • From 32 till 127, display usual ASCII
  • From 12352 till 12447, display Japanese Hiragana
  • ...

Points of interest

Get the symbol associated with a Unicode number

To print the symbol associated with a Unicode code, we need a way to build a one-character-long string that will contain the symbol we want (in fact, we need a modern equivalent of the good old BASIC function CHR$). To help us do that, .NET Framework provides the method UnicodeEncoding.Unicode.Getstring that converts numbers into a string of Unicode characters. The parameter to provide to UnicodeEncoding.Unicode.Getstring is a vector of bytes. If we want to make a string with only one character, we need to make a 2 bytes vector (because a Unicode code is 16 bits and we store 8 bits in each byte).

byte[] tmp=new byte[2];
StringBuilder textToAdd = new StringBuilder();
for (UInt32 i = start; i <= stop; i += step)
    for(UInt32 j=0;j<step;j++)
        tmp[0]=(byte) (i+j);
    textToAdd.Append( Environment.NewLine);

Using StringBuilder

The text generated by this program can be very long (especially if you ask to generate the full range of characters from 0 to 65535), and since we generate the text symbol by symbol, the number of string modifications is huge. This means that for such an application, using a normal "string" variable is impossible (the execution time would become much too long). That's why the use of a "StringBuilder" variable is mandatory (see code example above).

Make a text field to enter numbers

For this program, I needed a text input field that accepts only numbers. I tried the MaskedTextBox, but it was not working the way I wanted, so I preferred to use a standard TextBox and use the TextChanged event to check if the text was indeed a number.

private void textBoxNumeric_TextChanged(object sender, EventArgs e)
    UInt32 result;
    string newText;
    TextBox textBox = (TextBox)sender;
    if (UInt32.TryParse(textBox.Text, out result) || textBox.Text.Length==0)
        newText = textBox.Text;
        textBox.Tag = newText;
    { //not a valid number restore old value
        int caretPos=textBox.SelectionStart; 
        textBox.Text = (string)textBox.Tag;
        textBox.SelectionStart = caretPos - 1;

If the text is a correct number, then we store it to be able to restore this value in case of invalid input. The storage of the valid value is done in the Tag attribute of the TextBox instance. If the text is invalid (i.e., it is not a number), then we put back the old value that had been stored in the Tag attribute and we put back the caret (i.e., the flashing cursor in the text box) at the right place.


We have here a small tool that allows to see parts of (or even the full) Unicode table. Since it is displayed in a normal text box, you can copy those characters and paste them anywhere. You can even paste them inside the source code you edit with Visual Studio! This can be useful if you want your program to display strings that contain characters not available on your keyboard.


  • 12-31-2010: First version.
  • 02-01-2011: Corrected source code example format.


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


About the Author

pierre poliakoff
Team Leader
Belgium Belgium
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralUnispy Pin
Daniele Fusi3-Jan-11 3:18
memberDaniele Fusi3-Jan-11 3:18 
GeneralIs it Open Source (Re: Unispy) Pin
SAKryukov7-Jan-11 6:29
memberSAKryukov7-Jan-11 6:29 
GeneralRe: Is it Open Source (Re: Unispy) Pin
Daniele Fusi7-Jan-11 21:18
memberDaniele Fusi7-Jan-11 21:18 
GeneralRe: Is it Open Source (Re: Unispy) Pin
SAKryukov8-Jan-11 9:10
memberSAKryukov8-Jan-11 9:10 
GeneralMy vote of 4 Pin
SAKryukov2-Jan-11 7:21
memberSAKryukov2-Jan-11 7:21 
GeneralMy vote of 1 Pin
Michael Chourdakis2-Jan-11 4:12
memberMichael Chourdakis2-Jan-11 4:12 
GeneralRe: My vote of 1 Pin
SAKryukov2-Jan-11 7:18
memberSAKryukov2-Jan-11 7:18 
GeneralRe: My vote of 1 Pin
Michael Chourdakis2-Jan-11 8:51
memberMichael Chourdakis2-Jan-11 8:51 
GeneralRe: My vote of 1 Pin
pierre poliakoff2-Jan-11 11:05
memberpierre poliakoff2-Jan-11 11:05 
GeneralValid points; I agrue only against your vote of 1 (Re: My vote of 1) Pin
SAKryukov4-Jan-11 8:20
memberSAKryukov4-Jan-11 8:20 
GeneralUnicode is NOT a 16-bit code Pin
SAKryukov1-Jan-11 18:10
memberSAKryukov1-Jan-11 18:10 
GeneralRe: Unicode is NOT a 16-bit code Pin
pierre poliakoff1-Jan-11 22:48
memberpierre poliakoff1-Jan-11 22:48 
GeneralRe: Unicode is NOT a 16-bit code Pin
pierre poliakoff12-Jun-11 23:56
memberpierre poliakoff12-Jun-11 23:56 
Questioncharmap.exe? Pin
Axel Rietschin1-Jan-11 11:38
memberAxel Rietschin1-Jan-11 11:38 
AnswerRe: charmap.exe? Pin
pierre poliakoff1-Jan-11 22:22
memberpierre poliakoff1-Jan-11 22:22 
GeneralRe: charmap.exe? Pin
malangon5-Jan-11 2:58
membermalangon5-Jan-11 2:58 
GeneralHow come you did not see Unicode?! (Re: charmap.exe?) Pin
SAKryukov7-Jan-11 8:40
memberSAKryukov7-Jan-11 8:40 
GeneralRe: How come you did not see Unicode?! (Re: charmap.exe?) Pin
malangon10-Jan-11 3:05
membermalangon10-Jan-11 3:05 
GeneralRe: How come you did not see Unicode?! (Re: charmap.exe?) Pin
SAKryukov10-Jan-11 5:36
memberSAKryukov10-Jan-11 5:36 
GeneralRe: How come you did not see Unicode?! (Re: charmap.exe?) Pin
malangon10-Jan-11 6:15
membermalangon10-Jan-11 6:15 
GeneralRe: How come you did not see Unicode?! (Re: charmap.exe?) Pin
SAKryukov10-Jan-11 13:37
memberSAKryukov10-Jan-11 13:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170628.1 | Last Updated 2 Jan 2011
Article Copyright 2010 by pierre poliakoff
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid