In Notepad, when I type alt+216 it outputs a character that is not available on my keyboard keys.
I want to know how I can use this "alt+219" character in C# to generate a string containing this special character.
Is there a way to retrieve a list of these special characters?
I saw these in Office 2012 on the insert tab and in the symbols menu. What I want to know is if it is possible to generate all of them with standard C# syntax or something?
Example:
╪
It is very interesting to me that these characters work in the editor.
Yes, you can represent all Unicode characters in C#, including in string literals. There isn't so much a list of "special" characters as a whole range of charts to look at. Find the character you're interested in is U+256A, as can be seen in the box drawing chart ("BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE").
You can use the \u
character literal escaping format to represent the characters in C# code:
string text = "This is your character: \u256a";
The fact that the keys work in the editor is just part of Windows keyboard handling.
If you're having trouble finding a particular character, you can always save a file in Notepad using UTF-8, and then read it like this:
using System;
using System.IO;
class Test
{
static void Main()
{
string text = File.ReadAllText("foo.txt");
foreach (char c in text)
{
Console.WriteLine("{0} - {1:x4}", c, (int) c);
}
}
}
Be aware that some characters may not show up properly on the console (although the hex representation will).
See more on this question at Stackoverflow