123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- package main
- // I used iconv in door++, but it was horrible. It doesn't translate
- // control codes to Unicode.
- // This converts CP437 to Unicode for rendering in Unicode terminals
- // like the linux telnet client.
- // This does everything but: \x07, \x08, \x0a and \x0d.
- // 0x07, 0x08, 0x09, 0x0a, 0x0c, 0x0d, 0x1b (ANSI spec)
- func CP437_to_Unicode(cp437 string) string {
- var result string
- for _, char := range []byte(cp437) {
- // for _, char := range []rune(cp437) {
- switch int(char) {
- case 0x01:
- result += "\u263A"
- case 0x02:
- result += "\u263B"
- case 0x03:
- result += "\u2665"
- case 0x04:
- result += "\u2666"
- case 0x05:
- result += "\u2663"
- case 0x06:
- result += "\u2660"
- case 0x09:
- result += "\u25CB"
- case 0x0b:
- result += "\u2642"
- case 0x0c:
- result += "\u2640"
- case 0x0e:
- result += "\u266B"
- case 0x0f:
- result += "\u263C"
- case 0x10:
- result += "\u25BA"
- case 0x11:
- result += "\u25C4"
- case 0x12:
- result += "\u2195"
- case 0x13:
- result += "\u203C"
- case 0x14:
- result += "\xc2\xb6"
- case 0x15:
- result += "\xc2\xa7"
- case 0x16:
- result += "\u25AC"
- case 0x17:
- result += "\u21A8"
- case 0x18:
- result += "\u2191"
- case 0x19:
- result += "\u2193"
- case 0x1a:
- result += "\u2192"
- case 0x1c:
- result += "\u221F"
- case 0x1d:
- result += "\u2194"
- case 0x1e:
- result += "\u25B2"
- case 0x1f:
- result += "\u25BC"
- case 0x7f:
- result += "\u2302"
- case 0x80:
- result += "\xc3\x87"
- case 0x81:
- result += "\xc3\xbc"
- case 0x82:
- result += "\xc3\xa9"
- case 0x83:
- result += "\xc3\xa2"
- case 0x84:
- result += "\xc3\xa4"
- case 0x85:
- result += "\xc3\xa0"
- case 0x86:
- result += "\xc3\xa5"
- case 0x87:
- result += "\xc3\xa7"
- case 0x88:
- result += "\xc3\xaa"
- case 0x89:
- result += "\xc3\xab"
- case 0x8a:
- result += "\xc3\xa8"
- case 0x8b:
- result += "\xc3\xaf"
- case 0x8c:
- result += "\xc3\xae"
- case 0x8d:
- result += "\xc3\xac"
- case 0x8e:
- result += "\xc3\x84"
- case 0x8f:
- result += "\xc3\x85"
- case 0x90:
- result += "\xc3\x89"
- case 0x91:
- result += "\xc3\xa6"
- case 0x92:
- result += "\xc3\x86"
- case 0x93:
- result += "\xc3\xb4"
- case 0x94:
- result += "\xc3\xb6"
- case 0x95:
- result += "\xc3\xb2"
- case 0x96:
- result += "\xc3\xbb"
- case 0x97:
- result += "\xc3\xb9"
- case 0x98:
- result += "\xc3\xbf"
- case 0x99:
- result += "\xc3\x96"
- case 0x9a:
- result += "\xc3\x9c"
- case 0x9b:
- result += "\xc2\xa2"
- case 0x9c:
- result += "\xc2\xa3"
- case 0x9d:
- result += "\xc2\xa5"
- case 0x9e:
- result += "\u20A7"
- case 0x9f:
- result += "\u0192"
- case 0xa0:
- result += "\xc3\xa1"
- case 0xa1:
- result += "\xc3\xad"
- case 0xa2:
- result += "\xc3\xb3"
- case 0xa3:
- result += "\xc3\xba"
- case 0xa4:
- result += "\xc3\xb1"
- case 0xa5:
- result += "\xc3\x91"
- case 0xa6:
- result += "\xc2\xaa"
- case 0xa7:
- result += "\xc2\xba"
- case 0xa8:
- result += "\xc2\xbf"
- case 0xa9:
- result += "\u2310"
- case 0xaa:
- result += "\xc2\xac"
- case 0xab:
- result += "\xc2\xbd"
- case 0xac:
- result += "\xc2\xbc"
- case 0xad:
- result += "\xc2\xa1"
- case 0xae:
- result += "\xc2\xab"
- case 0xaf:
- result += "\xc2\xbb"
- case 0xb0:
- result += "\u2591"
- case 0xb1:
- result += "\u2592"
- case 0xb2:
- result += "\u2593"
- case 0xb3:
- result += "\u2502"
- case 0xb4:
- result += "\u2524"
- case 0xb5:
- result += "\u2561"
- case 0xb6:
- result += "\u2562"
- case 0xb7:
- result += "\u2556"
- case 0xb8:
- result += "\u2555"
- case 0xb9:
- result += "\u2563"
- case 0xba:
- result += "\u2551"
- case 0xbb:
- result += "\u2557"
- case 0xbc:
- result += "\u255D"
- case 0xbd:
- result += "\u255C"
- case 0xbe:
- result += "\u255B"
- case 0xbf:
- result += "\u2510"
- case 0xc0:
- result += "\u2514"
- case 0xc1:
- result += "\u2534"
- case 0xc2:
- result += "\u252C"
- case 0xc3:
- result += "\u251C"
- case 0xc4:
- result += "\u2500"
- case 0xc5:
- result += "\u253C"
- case 0xc6:
- result += "\u255E"
- case 0xc7:
- result += "\u255F"
- case 0xc8:
- result += "\u255A"
- case 0xc9:
- result += "\u2554"
- case 0xca:
- result += "\u2569"
- case 0xcb:
- result += "\u2566"
- case 0xcc:
- result += "\u2560"
- case 0xcd:
- result += "\u2550"
- case 0xce:
- result += "\u256C"
- case 0xcf:
- result += "\u2567"
- case 0xd0:
- result += "\u2568"
- case 0xd1:
- result += "\u2564"
- case 0xd2:
- result += "\u2565"
- case 0xd3:
- result += "\u2559"
- case 0xd4:
- result += "\u2558"
- case 0xd5:
- result += "\u2552"
- case 0xd6:
- result += "\u2553"
- case 0xd7:
- result += "\u256B"
- case 0xd8:
- result += "\u256A"
- case 0xd9:
- result += "\u2518"
- case 0xda:
- result += "\u250C"
- case 0xdb:
- result += "\u2588"
- case 0xdc:
- result += "\u2584"
- case 0xdd:
- result += "\u258C"
- case 0xde:
- result += "\u2590"
- case 0xdf:
- result += "\u2580"
- case 0xe0:
- result += "\u03B1"
- case 0xe1:
- result += "\xc3\x9f"
- case 0xe2:
- result += "\u0393"
- case 0xe3:
- result += "\u03C0"
- case 0xe4:
- result += "\u03A3"
- case 0xe5:
- result += "\u03C3"
- case 0xe6:
- result += "\xc2\xb5"
- case 0xe7:
- result += "\u03C4"
- case 0xe8:
- result += "\u03A6"
- case 0xe9:
- result += "\u0398"
- case 0xea:
- result += "\u03A9"
- case 0xeb:
- result += "\u03B4"
- case 0xec:
- result += "\u221E"
- case 0xed:
- result += "\u03C6"
- case 0xee:
- result += "\u03B5"
- case 0xef:
- result += "\u2229"
- case 0xf0:
- result += "\u2261"
- case 0xf1:
- result += "\xc2\xb1"
- case 0xf2:
- result += "\u2265"
- case 0xf3:
- result += "\u2264"
- case 0xf4:
- result += "\u2320"
- case 0xf5:
- result += "\u2321"
- case 0xf6:
- result += "\xc3\xb7"
- case 0xf7:
- result += "\u2248"
- case 0xf8:
- result += "\xc2\xb0"
- case 0xf9:
- result += "\u2219"
- case 0xfa:
- result += "\xc2\xb7"
- case 0xfb:
- result += "\u221A"
- case 0xfc:
- result += "\u207F"
- case 0xfd:
- result += "\xc2\xb2"
- case 0xfe:
- result += "\u25A0"
- case 0xff:
- result += "\xc2\xa0"
- default:
- result += string(char)
- }
- }
- return result
- }
|