Skip to content
Snippets Groups Projects
Commit 627c997d authored by rswindell's avatar rswindell
Browse files

More unicode code point definitions and Unicode -> CP437 translations.

parent dd9d7cd0
No related branches found
No related tags found
No related merge requests found
......@@ -351,8 +351,6 @@ size_t unicode_width(enum unicode_codepoint u)
char unicode_to_cp437(enum unicode_codepoint codepoint)
{
switch(codepoint) {
case 0: return '\0';
case UNICODE_ACUTE_ACCENT: return '\'';
case UNICODE_BROKEN_BAR: return '|';
......@@ -361,6 +359,8 @@ char unicode_to_cp437(enum unicode_codepoint codepoint)
case UNICODE_POUND_SIGN: return CP437_POUND_SIGN;
case UNICODE_YEN_SIGN: return CP437_YEN_SIGN;
case UNICODE_SECTION_SIGN: return CP437_SECTION_SIGN;
case UNICODE_DEGREE_CELSIUS:
case UNICODE_DEGREE_FAHRENHEIT:
case UNICODE_DEGREE_SIGN: return CP437_DEGREE_SIGN;
case UNICODE_PLUS_MINUS_SIGN: return CP437_PLUS_MINUS_SIGN;
case UNICODE_SUPERSCRIPT_TWO: return CP437_SUPERSCRIPT_TWO;
......@@ -462,15 +462,14 @@ char unicode_to_cp437(enum unicode_codepoint codepoint)
case UNICODE_EM_DASH:
return '\xC4';
case UNICODE_BULLET: // BULLET
return '\xF9';
case UNICODE_BULLET:
case UNICODE_BULLET_OPERATOR: return CP437_BULLET_OPERATOR;
case UNICODE_NO_BREAK_SPACE:
case UNICODE_EN_QUAD:
case UNICODE_EM_QUAD:
case UNICODE_EN_SPACE:
case UNICODE_EM_SPACE:
return ' ';
case UNICODE_EM_SPACE: return ' ';
case UNICODE_SQUARE_ROOT: return CP437_SQUARE_ROOT;
case UNICODE_CHECK_MARK:
......@@ -481,6 +480,10 @@ char unicode_to_cp437(enum unicode_codepoint codepoint)
case UNICODE_BALLOT_X:
case UNICODE_HEAVY_BALLOT_X: return 'x';
case UNICODE_DIVISION_SLASH: return '/';
case UNICODE_SET_MINUS: return '\\';
case UNICODE_ASTERISK_OPERATOR: return '*';
case UNICODE_OVERLINE:
case 0x2500: // Box Drawings Light Horizontal
case 0x2501: // Box Drawings Heavy Horizontal
......@@ -652,9 +655,41 @@ char unicode_to_cp437(enum unicode_codepoint codepoint)
case 0x2594: // Upper One Eighth Block
return '\xDF';
default: // Look for a 1:1 match in the CP437 -> Unicode table
case UNICODE_SMALL_COMMA:
case UNICODE_SMALL_IDEOGRAPHIC_COMMA: return ',';
case UNICODE_SMALL_FULL_STOP: return '.';
case UNICODE_SMALL_SEMICOLON: return ';';
case UNICODE_SMALL_COLON: return ':';
case UNICODE_SMALL_QUESTION_MARK: return '?';
case UNICODE_SMALL_EXCLAMATION_MARK: return '!';
case UNICODE_SMALL_EM_DASH: return '-';
case UNICODE_SMALL_LEFT_PARENTHESIS: return '(';
case UNICODE_SMALL_RIGHT_PARENTHESIS: return ')';
case UNICODE_SMALL_LEFT_CURLY_BRACKET: return '{';
case UNICODE_SMALL_RIGHT_CURLY_BRACKET: return '}';
case UNICODE_SMALL_LEFT_TORTOISE_SHELL_BRACKET: return '[';
case UNICODE_SMALL_RIGHT_TORTOISE_SHELL_BRACKET: return ']';
case UNICODE_SMALL_NUMBER_SIGN: return '#';
case UNICODE_SMALL_AMPERSAND: return '&';
case UNICODE_SMALL_ASTERISK: return '*';
case UNICODE_SMALL_PLUS_SIGN: return '+';
case UNICODE_SMALL_HYPHEN_MINUS: return '-';
case UNICODE_SMALL_LESS_THAN_SIGN: return '<';
case UNICODE_SMALL_GREATER_THAN_SIGN: return '>';
case UNICODE_SMALL_EQUALS_SIGN: return '=';
case UNICODE_SMALL_REVERSE_SOLIDUS: return '\\';
case UNICODE_SMALL_DOLLAR_SIGN: return '$';
case UNICODE_SMALL_PERCENT_SIGN: return '%';
case UNICODE_SMALL_COMMERCIAL_AT: return '@';
default:
{
int i;
if(codepoint >= UNICODE_FULLWIDTH_EXCLAMATION_MARK && codepoint <= UNICODE_FULLWIDTH_TILDE)
return '!' + (codepoint - UNICODE_FULLWIDTH_EXCLAMATION_MARK);
// Look for a 1:1 match in the CP437 -> Unicode table
for(i = 1; i < 0x100; i++) {
if(cp437_unicode_tbl[i] == codepoint)
return i;
......@@ -663,5 +698,5 @@ char unicode_to_cp437(enum unicode_codepoint codepoint)
}
}
return '\0'; // Not-mapped
return UNICODE_UNDEFINED; // Not-mapped
}
......@@ -274,6 +274,10 @@ enum unicode_codepoint {
UNICODE_UP_DOWN_ARROW_WITH_BASE = 0x21A8,
UNICODE_DIVISION_SLASH = 0x2215,
UNICODE_SET_MINUS = 0x2216,
UNICODE_ASTERISK_OPERATOR = 0x2217,
UNICODE_RING_OPERATOR = 0x2218,
UNICODE_BULLET_OPERATOR = 0x2219,
UNICODE_SQUARE_ROOT = 0x221A,
UNICODE_INFINITY = 0x221E,
......@@ -472,7 +476,36 @@ enum unicode_codepoint {
UNICODE_VARIATION_SELECTOR_16 = 0xFE0F,
UNICODE_ZERO_WIDTH_NO_BREAK_SPACE = 0xFEFF,
UNICODE_SMALL_COMMA = 0xFE50,
UNICODE_SMALL_IDEOGRAPHIC_COMMA = 0xFE51,
UNICODE_SMALL_FULL_STOP = 0xFE52,
UNICODE_SMALL_SEMICOLON = 0xFE54,
UNICODE_SMALL_COLON = 0xFE55,
UNICODE_SMALL_QUESTION_MARK = 0xFE56,
UNICODE_SMALL_EXCLAMATION_MARK = 0xFE57,
UNICODE_SMALL_EM_DASH = 0xFE58,
UNICODE_SMALL_LEFT_PARENTHESIS = 0xFE59,
UNICODE_SMALL_RIGHT_PARENTHESIS = 0xFE5A,
UNICODE_SMALL_LEFT_CURLY_BRACKET = 0xFE5B,
UNICODE_SMALL_RIGHT_CURLY_BRACKET = 0xFE5C,
UNICODE_SMALL_LEFT_TORTOISE_SHELL_BRACKET = 0xFE5D,
UNICODE_SMALL_RIGHT_TORTOISE_SHELL_BRACKET = 0xFE5E,
UNICODE_SMALL_NUMBER_SIGN = 0xFE5F,
UNICODE_SMALL_AMPERSAND = 0xFE60,
UNICODE_SMALL_ASTERISK = 0xFE61,
UNICODE_SMALL_PLUS_SIGN = 0xFE62,
UNICODE_SMALL_HYPHEN_MINUS = 0xFE63,
UNICODE_SMALL_LESS_THAN_SIGN = 0xFE64,
UNICODE_SMALL_GREATER_THAN_SIGN = 0xFE65,
UNICODE_SMALL_EQUALS_SIGN = 0xFE66,
UNICODE_SMALL_REVERSE_SOLIDUS = 0xFE68,
UNICODE_SMALL_DOLLAR_SIGN = 0xFE69,
UNICODE_SMALL_PERCENT_SIGN = 0xFE6A,
UNICODE_SMALL_COMMERCIAL_AT = 0xFE6B,
UNICODE_FULLWIDTH_EXCLAMATION_MARK = 0xFF01,
UNICODE_FULLWIDTH_TILDE = 0xFF5E,
UNICODE_FULLWIDTH_LEFT_WHITE_PARENTHESIS = 0xFF5F,
UNICODE_FULLWIDTH_RIGHT_WHITE_PARENTHESIS = 0xFF60,
UNICODE_HALFWIDTH_BLACK_SQUARE = 0xFFED,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment