Leaving The 8-bit World
We still kinda live in an 8-bit world. Our computer systems grew from simple terminals which could only show a limited set of characters. These typically supported ASCII characters and only eight bits long and focused on a US viewpoint of the world (‘a’-’z’,”A’-’Z’, ‘$’ and so on). In ASCII, an ‘a’ is 0x61 in hexadecimal, and 0110 0001 in binary.
But there’s a whole world of characters out there, and UTF-8 and UTF-16 open up a new world of character sets. For this, we can use Unicode, which allows us to support different character sets. Some examples are [here]:
Thus, a hex value which defines the code. For example, U+2800 to U+28FF give us Braille patterns [here]:
We can list some of the Unicode characters here:
To support this in a Web page, we need to add UTF-8 support:
<head>
<meta charset="UTF-8">
</head>
So, let’s create a Web page with these Braille codes. In C# we can take a word and then convert to Unicode with:
public static string getBraille(string s)
{
s = s.ToLower();
string rtn = "";
string[] mapping = { "⠁", "⠃", "⠉", "⠙",
"⠑", "⠋", "⠛", "⠓", "⠊",
"⠚", "⠅", "⠇", "⠍", "⠝", "⠕", "⠏","⠟", "⠗",
"⠎", "⠞",
"⠥", "⠧",
"⠺", "⠭", "⠽", "⠵" };
foreach (char ch in s )
{
int val = ((int)ch - (int)'a');
try
{
if (ch==' ') rtn = rtn + "⠀"+" ";
else rtn = rtn + mapping[val];
}
catch (Exception ex) { }
}
return (rtn);
}
In this case, the unicode for an ‘a’ in Braille is U+2801, and so we can use the HTML tag of “⠁”. We can then integrate this into our code with:
string message = "abc";
string s = getBraille(message);
ViewData["message"] = message;
string cryptedPassword = "<table><tr><td><div>Bob has left a secret message for Alice (see below). Can you find the message?</div></td></tr><tr><td><div><p style='font-size:70px; '>" + getBraille(message) + " </p></div></td></tr><tr><td><p style='font-size:20px;'><img src='/content/br.png' width='600px'/></td></tr></table>";
ViewData["c"] = cryptedPassword;
A sample is [here]:
You can try this out here: