Skip to content

Instantly share code, notes, and snippets.

@4poc
Created July 12, 2012 01:16
Show Gist options
  • Save 4poc/3094986 to your computer and use it in GitHub Desktop.
Save 4poc/3094986 to your computer and use it in GitHub Desktop.
Code page 437
/*
Code page 437 is the charset used by the original IBM PC,
it includes a wide variety of graphical symbols for ascii
drawings.
In this implementation I define unicode code points that
match the original cp437 symbols. The table also includes
the unique character name and if available the 7-bit
US-ASCII character.
References
==========
https://en.wikipedia.org/wiki/Code_page_437
http://unicode.org/Public/UNIDATA/NamesList.txt
*/
#ifndef CP437_H
#define CP437_H
namespace cp437 {
struct unicode_t {
const wchar_t symbol; // unicode character
const char ascii; // 7-bit ASCII if available
const std::string name; // unicode character name
};
const unicode_t table[] = {
{ 0, 0, "NULL" },
{ L'\u263A', 0, "WHITE SMILING FACE" },
{ L'\u263B', 0, "BLACK SMILING FACE" },
{ L'\u2665', 0, "BLACK HEART SUIT" },
{ L'\u2666', 0, "BLACK DIAMOND SUIT" },
{ L'\u2663', 0, "BLACK CLUB SUIT" },
{ L'\u2660', 0, "BLACK SPADE SUIT" },
{ L'\u2022', 0, "BULLET" },
{ L'\u25D8', 0, "INVERSE BULLET" },
{ L'\u25CB', 0, "WHITE CIRCLE" },
{ L'\u25D9', 0, "INVERSE WHITE CIRCLE" },
{ L'\u2642', 0, "MALE SIGN" },
{ L'\u2640', 0, "FEMALE SIGN" },
{ L'\u266A', 0, "EIGHTH NOTE" },
{ L'\u266B', 0, "BEAMED EIGHTH NOTES" },
{ L'\u263C', 0, "WHITE SUN WITH RAYS" },
{ L'\u25BA', 0, "BLACK RIGHT-POINTING POINTER" },
{ L'\u25C4', 0, "BLACK LEFT-POINTING POINTER" },
{ L'\u2195', 0, "UP DOWN ARROW" },
{ L'\u203C', 0, "DOUBLE EXCLAMATION MARK" },
{ L'\u00B6', 0, "PILCROW SIGN" },
{ L'\u00A7', 0, "SECTION SIGN" },
{ L'\u25AC', 0, "BLACK RECTANGLE" },
{ L'\u21A8', 0, "UP DOWN ARROW WITH BASE" },
{ L'\u2191', 0, "UPWARDS ARROW" },
{ L'\u2193', 0, "DOWNWARDS ARROW" },
{ L'\u2192', 0, "RIGHTWARDS ARROW" },
{ L'\u2190', 0, "LEFTWARDS ARROW" },
{ L'\u221F', 0, "RIGHT ANGLE" },
{ L'\u2194', 0, "LEFT RIGHT ARROW" },
{ L'\u25B2', 0, "BLACK UP-POINTING TRIANGLE" },
{ L'\u25BC', 0, "BLACK DOWN-POINTING TRIANGLE" },
{ L'\u0020', 0, "SPACE" },
{ L'\u0021', '!', "EXCLAMATION MARK" },
{ L'\u0022', '"', "QUOTATION MARK" },
{ L'\u0023', '#', "NUMBER SIGN" },
{ L'\u0024', '$', "DOLLAR SIGN" },
{ L'\u0025', '%', "PERCENT SIGN" },
{ L'\u0026', '&', "AMPERSAND" },
{ L'\u0027', '\'', "APOSTROPHE" },
{ L'\u0028', '(', "LEFT PARENTHESIS" },
{ L'\u0029', ')', "RIGHT PARENTHESIS" },
{ L'\u002A', '*', "ASTERISK" },
{ L'\u002B', '+', "PLUS SIGN" },
{ L'\u002C', ',', "COMMA" },
{ L'\u002D', '-', "HYPHEN-MINUS" },
{ L'\u002E', '.', "FULL STOP" },
{ L'\u002F', '/', "SOLIDUS" },
{ L'\u0030', '0', "DIGIT ZERO" },
{ L'\u0031', '1', "DIGIT ONE" },
{ L'\u0032', '2', "DIGIT TWO" },
{ L'\u0033', '3', "DIGIT THREE" },
{ L'\u0034', '4', "DIGIT FOUR" },
{ L'\u0035', '5', "DIGIT FIVE" },
{ L'\u0036', '6', "DIGIT SIX" },
{ L'\u0037', '7', "DIGIT SEVEN" },
{ L'\u0038', '8', "DIGIT EIGHT" },
{ L'\u0039', '9', "DIGIT NINE" },
{ L'\u003A', ':', "COLON" },
{ L'\u003B', ';', "SEMICOLON" },
{ L'\u003C', '<', "LESS-THAN SIGN" },
{ L'\u003D', '=', "EQUALS SIGN" },
{ L'\u003E', '>', "GREATER-THAN SIGN" },
{ L'\u003F', '?', "QUESTION MARK" },
{ L'\u0040', '@', "COMMERCIAL AT" },
{ L'\u0041', 'A', "LATIN CAPITAL LETTER A" },
{ L'\u0042', 'B', "LATIN CAPITAL LETTER B" },
{ L'\u0043', 'C', "LATIN CAPITAL LETTER C" },
{ L'\u0044', 'D', "LATIN CAPITAL LETTER D" },
{ L'\u0045', 'E', "LATIN CAPITAL LETTER E" },
{ L'\u0046', 'F', "LATIN CAPITAL LETTER F" },
{ L'\u0047', 'G', "LATIN CAPITAL LETTER G" },
{ L'\u0048', 'H', "LATIN CAPITAL LETTER H" },
{ L'\u0049', 'I', "LATIN CAPITAL LETTER I" },
{ L'\u004A', 'J', "LATIN CAPITAL LETTER J" },
{ L'\u004B', 'K', "LATIN CAPITAL LETTER K" },
{ L'\u004C', 'L', "LATIN CAPITAL LETTER L" },
{ L'\u004D', 'M', "LATIN CAPITAL LETTER M" },
{ L'\u004E', 'N', "LATIN CAPITAL LETTER N" },
{ L'\u004F', 'O', "LATIN CAPITAL LETTER O" },
{ L'\u0050', 'P', "LATIN CAPITAL LETTER P" },
{ L'\u0051', 'Q', "LATIN CAPITAL LETTER Q" },
{ L'\u0052', 'R', "LATIN CAPITAL LETTER R" },
{ L'\u0053', 'S', "LATIN CAPITAL LETTER S" },
{ L'\u0054', 'T', "LATIN CAPITAL LETTER T" },
{ L'\u0055', 'U', "LATIN CAPITAL LETTER U" },
{ L'\u0056', 'V', "LATIN CAPITAL LETTER V" },
{ L'\u0057', 'W', "LATIN CAPITAL LETTER W" },
{ L'\u0058', 'X', "LATIN CAPITAL LETTER X" },
{ L'\u0059', 'Y', "LATIN CAPITAL LETTER Y" },
{ L'\u005A', 'Z', "LATIN CAPITAL LETTER Z" },
{ L'\u005B', '[', "LEFT SQUARE BRACKET" },
{ L'\u005C', '\\', "REVERSE SOLIDUS" },
{ L'\u005D', ']', "RIGHT SQUARE BRACKET" },
{ L'\u005E', '^', "CIRCUMFLEX ACCENT" },
{ L'\u005F', '_', "LOW LINE" },
{ L'\u0060', '`', "GRAVE ACCENT" },
{ L'\u0061', 'a', "LATIN SMALL LETTER A" },
{ L'\u0062', 'b', "LATIN SMALL LETTER B" },
{ L'\u0063', 'c', "LATIN SMALL LETTER C" },
{ L'\u0064', 'd', "LATIN SMALL LETTER D" },
{ L'\u0065', 'e', "LATIN SMALL LETTER E" },
{ L'\u0066', 'f', "LATIN SMALL LETTER F" },
{ L'\u0067', 'g', "LATIN SMALL LETTER G" },
{ L'\u0068', 'h', "LATIN SMALL LETTER H" },
{ L'\u0069', 'i', "LATIN SMALL LETTER I" },
{ L'\u006A', 'j', "LATIN SMALL LETTER J" },
{ L'\u006B', 'k', "LATIN SMALL LETTER K" },
{ L'\u006C', 'l', "LATIN SMALL LETTER L" },
{ L'\u006D', 'm', "LATIN SMALL LETTER M" },
{ L'\u006E', 'n', "LATIN SMALL LETTER N" },
{ L'\u006F', 'o', "LATIN SMALL LETTER O" },
{ L'\u0070', 'p', "LATIN SMALL LETTER P" },
{ L'\u0071', 'q', "LATIN SMALL LETTER Q" },
{ L'\u0072', 'r', "LATIN SMALL LETTER R" },
{ L'\u0073', 's', "LATIN SMALL LETTER S" },
{ L'\u0074', 't', "LATIN SMALL LETTER T" },
{ L'\u0075', 'u', "LATIN SMALL LETTER U" },
{ L'\u0076', 'v', "LATIN SMALL LETTER V" },
{ L'\u0077', 'w', "LATIN SMALL LETTER W" },
{ L'\u0078', 'x', "LATIN SMALL LETTER X" },
{ L'\u0079', 'y', "LATIN SMALL LETTER Y" },
{ L'\u007A', 'z', "LATIN SMALL LETTER Z" },
{ L'\u007B', '{', "LEFT CURLY BRACKET" },
{ L'\u007C', '|', "VERTICAL LINE" },
{ L'\u007D', '}', "RIGHT CURLY BRACKET" },
{ L'\u007E', '~', "TILDE" },
{ L'\u2302', 0, "HOUSE" },
{ L'\u00C7', 0, "LATIN CAPITAL LETTER C WITH CEDILLA" },
{ L'\u00FC', 0, "LATIN SMALL LETTER U WITH DIAERESIS" },
{ L'\u00E9', 0, "LATIN SMALL LETTER E WITH ACUTE" },
{ L'\u00E2', 0, "LATIN SMALL LETTER A WITH CIRCUMFLEX" },
{ L'\u00E4', 0, "LATIN SMALL LETTER A WITH DIAERESIS" },
{ L'\u00E0', 0, "LATIN SMALL LETTER A WITH GRAVE" },
{ L'\u00E5', 0, "LATIN SMALL LETTER A WITH RING ABOVE" },
{ L'\u00E7', 0, "LATIN SMALL LETTER C WITH CEDILLA" },
{ L'\u00EA', 0, "LATIN SMALL LETTER E WITH CIRCUMFLEX" },
{ L'\u00EB', 0, "LATIN SMALL LETTER E WITH DIAERESIS" },
{ L'\u00E8', 0, "LATIN SMALL LETTER E WITH GRAVE" },
{ L'\u00EF', 0, "LATIN SMALL LETTER I WITH DIAERESIS" },
{ L'\u00EE', 0, "LATIN SMALL LETTER I WITH CIRCUMFLEX" },
{ L'\u00EC', 0, "LATIN SMALL LETTER I WITH GRAVE" },
{ L'\u00C4', 0, "LATIN CAPITAL LETTER A WITH DIAERESIS" },
{ L'\u00C5', 0, "LATIN CAPITAL LETTER A WITH RING ABOVE" },
{ L'\u00C9', 0, "LATIN CAPITAL LETTER E WITH ACUTE" },
{ L'\u00E6', 0, "LATIN SMALL LETTER AE" },
{ L'\u00C6', 0, "LATIN CAPITAL LETTER AE" },
{ L'\u00F4', 0, "LATIN SMALL LETTER O WITH CIRCUMFLEX" },
{ L'\u00F6', 0, "LATIN SMALL LETTER O WITH DIAERESIS" },
{ L'\u00F2', 0, "LATIN SMALL LETTER O WITH GRAVE" },
{ L'\u00FB', 0, "LATIN SMALL LETTER U WITH CIRCUMFLEX" },
{ L'\u00F9', 0, "LATIN SMALL LETTER U WITH GRAVE" },
{ L'\u00FF', 0, "LATIN SMALL LETTER Y WITH DIAERESIS" },
{ L'\u00D6', 0, "LATIN CAPITAL LETTER O WITH DIAERESIS" },
{ L'\u00DC', 0, "LATIN CAPITAL LETTER U WITH DIAERESIS" },
{ L'\u00A2', 0, "CENT SIGN" },
{ L'\u00A3', 0, "POUND SIGN" },
{ L'\u00A5', 0, "YEN SIGN" },
{ L'\u20A7', 0, "PESETA SIGN" },
{ L'\u0192', 0, "LATIN SMALL LETTER F WITH HOOK" },
{ L'\u00E1', 0, "LATIN SMALL LETTER A WITH ACUTE" },
{ L'\u00ED', 0, "LATIN SMALL LETTER I WITH ACUTE" },
{ L'\u00F3', 0, "LATIN SMALL LETTER O WITH ACUTE" },
{ L'\u00FA', 0, "LATIN SMALL LETTER U WITH ACUTE" },
{ L'\u00F1', 0, "LATIN SMALL LETTER N WITH TILDE" },
{ L'\u00D1', 0, "LATIN CAPITAL LETTER N WITH TILDE" },
{ L'\u00AA', 0, "FEMININE ORDINAL INDICATOR" },
{ L'\u00BA', 0, "MASCULINE ORDINAL INDICATOR" },
{ L'\u00BF', 0, "INVERTED QUESTION MARK" },
{ L'\u2310', 0, "REVERSED NOT SIGN" },
{ L'\u00AC', 0, "NOT SIGN" },
{ L'\u00BD', 0, "VULGAR FRACTION ONE HALF" },
{ L'\u00BC', 0, "VULGAR FRACTION ONE QUARTER" },
{ L'\u00A1', 0, "INVERTED EXCLAMATION MARK" },
{ L'\u00AB', 0, "LEFT-POINTING DOUBLE ANGLE QUOTATION MARK" },
{ L'\u00BB', 0, "RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK" },
{ L'\u2591', 0, "LIGHT SHADE" },
{ L'\u2592', 0, "MEDIUM SHADE" },
{ L'\u2593', 0, "DARK SHADE" },
{ L'\u2502', 0, "BOX DRAWINGS LIGHT VERTICAL" },
{ L'\u2524', 0, "BOX DRAWINGS LIGHT VERTICAL AND LEFT" },
{ L'\u2561', 0, "BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE" },
{ L'\u2562', 0, "BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE" },
{ L'\u2556', 0, "BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE" },
{ L'\u2555', 0, "BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE" },
{ L'\u2563', 0, "BOX DRAWINGS DOUBLE VERTICAL AND LEFT" },
{ L'\u2551', 0, "BOX DRAWINGS DOUBLE VERTICAL" },
{ L'\u2557', 0, "BOX DRAWINGS DOUBLE DOWN AND LEFT" },
{ L'\u255D', 0, "BOX DRAWINGS DOUBLE UP AND LEFT" },
{ L'\u255C', 0, "BOX DRAWINGS UP DOUBLE AND LEFT SINGLE" },
{ L'\u255B', 0, "BOX DRAWINGS UP SINGLE AND LEFT DOUBLE" },
{ L'\u2510', 0, "BOX DRAWINGS LIGHT DOWN AND LEFT" },
{ L'\u2514', 0, "BOX DRAWINGS LIGHT UP AND RIGHT" },
{ L'\u2534', 0, "BOX DRAWINGS LIGHT UP AND HORIZONTAL" },
{ L'\u252C', 0, "BOX DRAWINGS LIGHT DOWN AND HORIZONTAL" },
{ L'\u251C', 0, "BOX DRAWINGS LIGHT VERTICAL AND RIGHT" },
{ L'\u2500', 0, "BOX DRAWINGS LIGHT HORIZONTAL" },
{ L'\u253C', 0, "BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL" },
{ L'\u255E', 0, "BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE" },
{ L'\u255F', 0, "BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE" },
{ L'\u255A', 0, "BOX DRAWINGS DOUBLE UP AND RIGHT" },
{ L'\u2554', 0, "BOX DRAWINGS DOUBLE DOWN AND RIGHT" },
{ L'\u2569', 0, "BOX DRAWINGS DOUBLE UP AND HORIZONTAL" },
{ L'\u2566', 0, "BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL" },
{ L'\u2560', 0, "BOX DRAWINGS DOUBLE VERTICAL AND RIGHT" },
{ L'\u2550', 0, "BOX DRAWINGS DOUBLE HORIZONTAL" },
{ L'\u256C', 0, "BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL" },
{ L'\u2567', 0, "BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE" },
{ L'\u2568', 0, "BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE" },
{ L'\u2564', 0, "BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE" },
{ L'\u2565', 0, "BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE" },
{ L'\u2559', 0, "BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE" },
{ L'\u2558', 0, "BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE" },
{ L'\u2552', 0, "BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE" },
{ L'\u2553', 0, "BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE" },
{ L'\u256B', 0, "BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE" },
{ L'\u256A', 0, "BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE" },
{ L'\u2518', 0, "BOX DRAWINGS LIGHT UP AND LEFT" },
{ L'\u250C', 0, "BOX DRAWINGS LIGHT DOWN AND RIGHT" },
{ L'\u2588', 0, "FULL BLOCK" },
{ L'\u2584', 0, "LOWER HALF BLOCK" },
{ L'\u258C', 0, "LEFT HALF BLOCK" },
{ L'\u2590', 0, "RIGHT HALF BLOCK" },
{ L'\u2580', 0, "UPPER HALF BLOCK" },
{ L'\u03B1', 0, "GREEK SMALL LETTER ALPHA" },
{ L'\u00DF', 0, "LATIN SMALL LETTER SHARP S" },
{ L'\u0393', 0, "GREEK CAPITAL LETTER GAMMA" },
{ L'\u03C0', 0, "GREEK SMALL LETTER PI" },
{ L'\u03A3', 0, "GREEK CAPITAL LETTER SIGMA" },
{ L'\u03C3', 0, "GREEK SMALL LETTER SIGMA" },
{ L'\u00B5', 0, "MICRO SIGN" },
{ L'\u03C4', 0, "GREEK SMALL LETTER TAU" },
{ L'\u03A6', 0, "GREEK CAPITAL LETTER PHI" },
{ L'\u0398', 0, "GREEK CAPITAL LETTER THETA" },
{ L'\u03A9', 0, "GREEK CAPITAL LETTER OMEGA" },
{ L'\u03B4', 0, "GREEK SMALL LETTER DELTA" },
{ L'\u221E', 0, "INFINITY" },
{ L'\u03C6', 0, "GREEK SMALL LETTER PHI" },
{ L'\u03B5', 0, "GREEK SMALL LETTER EPSILON" },
{ L'\u2229', 0, "INTERSECTION" },
{ L'\u2261', 0, "IDENTICAL TO" },
{ L'\u00B1', 0, "PLUS-MINUS SIGN" },
{ L'\u2265', 0, "GREATER-THAN OR EQUAL TO" },
{ L'\u2264', 0, "LESS-THAN OR EQUAL TO" },
{ L'\u2320', 0, "TOP HALF INTEGRAL" },
{ L'\u2321', 0, "BOTTOM HALF INTEGRAL" },
{ L'\u00F7', 0, "DIVISION SIGN" },
{ L'\u2248', 0, "ALMOST EQUAL TO" },
{ L'\u00B0', 0, "DEGREE SIGN" },
{ L'\u2219', 0, "BULLET OPERATOR" },
{ L'\u00B7', 0, "MIDDLE DOT" },
{ L'\u221A', 0, "SQUARE ROOT" },
{ L'\u207F', 0, "SUPERSCRIPT LATIN SMALL LETTER N" },
{ L'\u00B2', 0, "SUPERSCRIPT TWO" },
{ L'\u25A0', 0, "BLACK SQUARE" },
{ L'\u00A0', 0, "NO-BREAK SPACE" }
};
const size_t table_size =
sizeof (table) / sizeof (table[0]);
}
#endif // CP437_H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment