Commits

Trammell Hudson committed 5b0ddb1

Varicode table generation

Comments (0)

Files changed (2)

+static const uint16_t varicode[256] = {
+	[0x00] = 1aa80, // 1010101011 NUL
+	[0x01] = 1b680, // 1011011011 SOH
+	[0x02] = 16e80, // 1011101101 STX
+	[0x03] = 1dd80, // 1101110111 ETX
+	[0x04] = 1ae80, // 1011101011 EOT
+	[0x05] = 1f580, // 1101011111 ENQ
+	[0x06] = 1ee80, // 1011101111 ACK
+	[0x07] = 17e80, // 1011111101 BEL
+	[0x08] = 1fe80, // 1011111111 BS
+	[0x09] = 1ee00, // 11101111 HT
+	[0x0a] = 17000, // 11101 LF
+	[0x0b] = 1ed80, // 1101101111 VT
+	[0x0c] = 17680, // 1011011101 FF
+	[0x0d] = 1f000, // 11111 CR
+	[0x0e] = 15d80, // 1101110101 SO
+	[0x0f] = 1ab80, // 1110101011 SI
+	[0x10] = 1de80, // 1011110111 DLE
+	[0x11] = 15e80, // 1011110101 DC1
+	[0x12] = 16b80, // 1110101101 DC2
+	[0x13] = 1eb80, // 1110101111 DC3
+	[0x14] = 1b580, // 1101011011 DC4
+	[0x15] = 1ad80, // 1101101011 NAK
+	[0x16] = 16d80, // 1101101101 SYN
+	[0x17] = 1d580, // 1101010111 ETB
+	[0x18] = 1bd80, // 1101111011 CAN
+	[0x19] = 17d80, // 1101111101 EM
+	[0x1a] = 1db80, // 1110110111 SUB
+	[0x1b] = 15580, // 1101010101 ESC
+	[0x1c] = 17580, // 1101011101 FS
+	[0x1d] = 1bb80, // 1110111011 GS
+	[0x1e] = 1be80, // 1011111011 RS
+	[0x1f] = 1fd80, // 1101111111 US
+	[0x20] = 10000, // 1 [[Space (punctuation)|SP]]
+	[0x21] = 1ff00, // 111111111 [[Exclamation mark|!]]
+	[0x22] = 1f500, // 101011111 [[Quotation mark|"]]
+	[0x23] = 15f00, // 111110101 [[Number sign|#]]
+	[0x24] = 1b700, // 111011011 [[Dollar sign|$]]
+	[0x25] = 15680, // 1011010101 [[Percent sign|%]]
+	[0x26] = 1ba80, // 1010111011 [[Ampersand|&]]
+	[0x27] = 1fd00, // 101111111 [[Apostrophe (punctuation)|']]
+	[0x28] = 1be00, // 11111011 [[Bracket|(]]
+	[0x29] = 1de00, // 11110111 [[Bracket|)]]
+	[0x2a] = 1ed00, // 101101111 [[Asterisk|*]]
+	[0x2b] = 1f700, // 111011111 [[Plus sign|+]]
+	[0x2c] = 15c00, // 1110101 [[Comma (punctuation)|,]]
+	[0x2d] = 15800, // 110101 [[Hyphen|-]]
+	[0x2e] = 1d400, // 1010111 [[Full stop|.]]
+	[0x2f] = 1eb00, // 110101111 [[Slash (punctuation)|/]]
+	[0x30] = 1da00, // 10110111 [[0 (number)|0]]
+	[0x31] = 17a00, // 10111101 [[1 (number)|1]]
+	[0x32] = 16e00, // 11101101 [[2 (number)|2]]
+	[0x33] = 1fe00, // 11111111 [[3 (number)|3]]
+	[0x34] = 1dd00, // 101110111 [[4 (number)|4]]
+	[0x35] = 1b500, // 101011011 [[5 (number)|5]]
+	[0x36] = 1ad00, // 101101011 [[6 (number)|6]]
+	[0x37] = 16b00, // 110101101 [[7 (number)|7]]
+	[0x38] = 1ab00, // 110101011 [[8 (number)|8]]
+	[0x39] = 1db00, // 110110111 [[9 (number)|9]]
+	[0x3a] = 15e00, // 11110101 [[Colon (punctuation)|:]]
+	[0x3b] = 17b00, // 110111101 [[Semicolon|;]]
+	[0x3c] = 16f00, // 111101101 [[Less-than sign|<]]
+	[0x3d] = 15400, // 1010101 [[Equals sign|=]]
+	[0x3e] = 1d700, // 111010111 [[Greater-than sign|>]]
+	[0x3f] = 1ea80, // 1010101111 [[Question mark|?]]
+	[0x40] = 17a80, // 1010111101 [[@]]
+	[0x41] = 17c00, // 1111101 [[A]]
+	[0x42] = 1ae00, // 11101011 [[B]]
+	[0x43] = 16a00, // 10101101 [[C]]
+	[0x44] = 15a00, // 10110101 [[D]]
+	[0x45] = 1dc00, // 1110111 [[E]]
+	[0x46] = 1b600, // 11011011 [[F]]
+	[0x47] = 17e00, // 11111101 [[G]]
+	[0x48] = 15500, // 101010101 [[H]]
+	[0x49] = 1fc00, // 1111111 [[I]]
+	[0x4a] = 17f00, // 111111101 [[J]]
+	[0x4b] = 17d00, // 101111101 [[K]]
+	[0x4c] = 1d600, // 11010111 [[L]]
+	[0x4d] = 1ba00, // 10111011 [[M]]
+	[0x4e] = 17600, // 11011101 [[N]]
+	[0x4f] = 1aa00, // 10101011 [[O]]
+	[0x50] = 15600, // 11010101 [[P]]
+	[0x51] = 17700, // 111011101 [[Q]]
+	[0x52] = 1ea00, // 10101111 [[R]]
+	[0x53] = 1ec00, // 1101111 [[S]]
+	[0x54] = 16c00, // 1101101 [[T]]
+	[0x55] = 1d500, // 101010111 [[U]]
+	[0x56] = 15b00, // 110110101 [[V]]
+	[0x57] = 17500, // 101011101 [[W]]
+	[0x58] = 15d00, // 101110101 [[X]]
+	[0x59] = 1bd00, // 101111011 [[Y]]
+	[0x5a] = 16a80, // 1010101101 [[Z]]
+	[0x5b] = 1df00, // 111110111 [[Bracket|<nowiki>[</nowiki>]]
+	[0x5c] = 1ef00, // 111101111 [[Backslash|\]]
+	[0x5d] = 1bf00, // 111111011 [[Bracket|<nowiki>]</nowiki>]]
+	[0x5e] = 1fa80, // 1010111111 [[Caret|^]]
+	[0x5f] = 16d00, // 101101101 [[Underscore|_]]
+	[0x60] = 1f680, // 1011011111 [[Grave accent|`]]
+	[0x61] = 1a000, // 1011 [[a]]
+	[0x62] = 1f400, // 1011111 [[b]]
+	[0x63] = 1e800, // 101111 [[c]]
+	[0x64] = 16800, // 101101 [[d]]
+	[0x65] = 18000, // 11 [[e]]
+	[0x66] = 17800, // 111101 [[f]]
+	[0x67] = 1b400, // 1011011 [[g]]
+	[0x68] = 1a800, // 101011 [[h]]
+	[0x69] = 16000, // 1101 [[i]]
+	[0x6a] = 1af00, // 111101011 [[j]]
+	[0x6b] = 1fa00, // 10111111 [[k]]
+	[0x6c] = 1b000, // 11011 [[l]]
+	[0x6d] = 1b800, // 111011 [[m]]
+	[0x6e] = 1e000, // 1111 [[n]]
+	[0x6f] = 1c000, // 111 [[o]]
+	[0x70] = 1f800, // 111111 [[p]]
+	[0x71] = 1fb00, // 110111111 [[q]]
+	[0x72] = 15000, // 10101 [[r]]
+	[0x73] = 1d000, // 10111 [[s]]
+	[0x74] = 14000, // 101 [[t]]
+	[0x75] = 1d800, // 110111 [[u]]
+	[0x76] = 1bc00, // 1111011 [[v]]
+	[0x77] = 1ac00, // 1101011 [[w]]
+	[0x78] = 1f600, // 11011111 [[x]]
+	[0x79] = 17400, // 1011101 [[y]]
+	[0x7a] = 15700, // 111010101 [[z]]
+	[0x7b] = 1da80, // 1010110111 [[Bracket|&#123;]]
+	[0x7c] = 1bb00, // 110111011 [[Vertical bar|&#124;]]
+	[0x7d] = 15a80, // 1010110101 [[Bracket|&#125;]]
+	[0x7e] = 1d680, // 1011010111 [[Tilde|~]]
+	[0x7f] = 15b80, // 1110110101 DEL
+};
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+print "static const uint16_t varicode[256] = {\n";
+
+while (<DATA>)
+{
+	chomp;
+	my ($bits,undef,undef,$hex,$name) = split / \|\| /;
+
+	my $word = 0;
+	die "$bits => $hex too long\n"
+		if length $bits > 16;
+
+	for my $bit (split //, $bits)
+	{
+		$word = ($word >> 1) | ($bit << 16);
+	}
+
+	printf "\t[0x%02x] = %04x, // %s %s\n",
+		hex $hex,
+		$word,
+		$bits,
+		$name,
+		;
+}
+
+print "};\n";
+		
+__DATA__
+1010101011 || 000 || 0 || 00 || NUL || [[Null character]]
+1011011011 || 001 || 1 || 01 || SOH || Start of Header
+1011101101 || 002 || 2 || 02 || STX || Start of Text
+1101110111 || 003 || 3 || 03 || ETX || End of Text
+1011101011 || 004 || 4 || 04 || EOT || [[End-of-transmission character|End of Transmission]]
+1101011111 || 005 || 5 || 05 || ENQ ||  Enquiry
+1011101111 || 006 || 6 || 06 || ACK || [[Acknowledge character|Acknowledgment]]
+1011111101 || 007 || 7 || 07 || BEL || [[Bell character|Bell]]
+1011111111 || 010 || 8 || 08 || BS || [[Backspace]]
+11101111 || 011 || 9 || 09 || HT || [[Tab key|Horizontal Tab]]
+11101 || 012 || 10 || 0A || LF || [[Line feed]]
+1101101111 || 013 || 11 || 0B || VT || Vertical Tab
+1011011101 || 014 || 12 || 0C || FF || [[Form feed]]
+11111 || 015 || 13 || 0D || CR || [[Carriage return]]
+1101110101 || 016 || 14 || 0E || SO || [[Shift Out and Shift In characters|Shift Out]]
+1110101011 || 017 || 15 || 0F || SI || [[Shift Out and Shift In characters|Shift In]]
+1011110111 || 020 || 16 || 10 || DLE || Data Link Escape
+1011110101 || 021 || 17 || 11 || DC1 || Device Control 1 (XON)
+1110101101 || 022 || 18 || 12 || DC2 || Device Control 2
+1110101111 || 023 || 19 || 13 || DC3 || Device Control 3 (XOFF)
+1101011011 || 024 || 20 || 14 || DC4 || Device Control 4
+1101101011 || 025 || 21 || 15 || NAK || [[Negative-acknowledge character|Negative Acknowledgement]]
+1101101101 || 026 || 22 || 16 || SYN || Synchronous Idle
+1101010111 || 027 || 23 || 17 || ETB || End of Trans. Block
+1101111011 || 030 || 24 || 18 || CAN || [[Cancel character|Cancel]]
+1101111101 || 031 || 25 || 19 || EM || End of Medium
+1110110111 || 032 || 26 || 1A || SUB || [[Substitute character|Substitute]]
+1101010101 || 033 || 27 || 1B || ESC || [[Escape character|Escape]]
+1101011101 || 034 || 28 || 1C || FS || File Separator
+1110111011 || 035 || 29 || 1D || GS || Group Separator
+1011111011 || 036 || 30 || 1E || RS || Record Separator
+1101111111 || 037 || 31 || 1F || US || Unit Separator
+1 || 040 || 32 || 20 || [[Space (punctuation)|SP]]
+111111111 || 041 || 33 || 21 || [[Exclamation mark|!]]
+101011111 || 042 || 34 || 22 || [[Quotation mark|"]]
+111110101 || 043 || 35 || 23 || [[Number sign|#]]
+111011011 || 044 || 36 || 24 || [[Dollar sign|$]]
+1011010101 || 045 || 37 || 25 || [[Percent sign|%]]
+1010111011 || 046 || 38 || 26 || [[Ampersand|&]]
+101111111 || 047 || 39 || 27 || [[Apostrophe (punctuation)|']]
+11111011 || 050 || 40 || 28 || [[Bracket|(]]
+11110111 || 051 || 41 || 29 || [[Bracket|)]]
+101101111 || 052 || 42 || 2A || [[Asterisk|*]]
+111011111 || 053 || 43 || 2B || [[Plus sign|+]]
+1110101 || 054 || 44 || 2C || [[Comma (punctuation)|,]]
+110101 || 055 || 45 || 2D || [[Hyphen|-]]
+1010111 || 056 || 46 || 2E || [[Full stop|.]]
+110101111 || 057 || 47 || 2F || [[Slash (punctuation)|/]]
+10110111 || 060 || 48 || 30 || [[0 (number)|0]]
+10111101 || 061 || 49 || 31 || [[1 (number)|1]]
+11101101 || 062 || 50 || 32 || [[2 (number)|2]]
+11111111 || 063 || 51 || 33 || [[3 (number)|3]]
+101110111 || 064 || 52 || 34 || [[4 (number)|4]]
+101011011 || 065 || 53 || 35 || [[5 (number)|5]]
+101101011 || 066 || 54 || 36 || [[6 (number)|6]]
+110101101 || 067 || 55 || 37 || [[7 (number)|7]]
+110101011 || 070 || 56 || 38 || [[8 (number)|8]]
+110110111 || 071 || 57 || 39 || [[9 (number)|9]]
+11110101 || 072 || 58 || 3A || [[Colon (punctuation)|:]]
+110111101 || 073 || 59 || 3B || [[Semicolon|;]]
+111101101 || 074 || 60 || 3C || [[Less-than sign|<]]
+1010101 || 075 || 61 || 3D || [[Equals sign|=]]
+111010111 || 076 || 62 || 3E || [[Greater-than sign|>]]
+1010101111 || 077 || 63 || 3F || [[Question mark|?]]
+1010111101 || 100 || 64 || 40 || [[@]]
+1111101 || 101 || 65 || 41 || [[A]]
+11101011 || 102 || 66 || 42 || [[B]]
+10101101 || 103 || 67 || 43 || [[C]]
+10110101 || 104 || 68 || 44 || [[D]]
+1110111 || 105 || 69 || 45 || [[E]]
+11011011 || 106 || 70 || 46 || [[F]]
+11111101 || 107 || 71 || 47 || [[G]]
+101010101 || 110 || 72 || 48 || [[H]]
+1111111 || 111 || 73 || 49 || [[I]]
+111111101 || 112 || 74 || 4A || [[J]]
+101111101 || 113 || 75 || 4B || [[K]]
+11010111 || 114 || 76 || 4C || [[L]]
+10111011 || 115 || 77 || 4D || [[M]]
+11011101 || 116 || 78 || 4E || [[N]]
+10101011 || 117 || 79 || 4F || [[O]]
+11010101 || 120 || 80 || 50 || [[P]]
+111011101 || 121 || 81 || 51 || [[Q]]
+10101111 || 122 || 82 || 52 || [[R]]
+1101111 || 123 || 83 || 53 || [[S]]
+1101101 || 124 || 84 || 54 || [[T]]
+101010111 || 125 || 85 || 55 || [[U]]
+110110101 || 126 || 86 || 56 || [[V]]
+101011101 || 127 || 87 || 57 || [[W]]
+101110101 || 130 || 88 || 58 || [[X]]
+101111011 || 131 || 89 || 59 || [[Y]]
+1010101101 || 132 || 90 || 5A || [[Z]]
+111110111 || 133 || 91 || 5B || [[Bracket|<nowiki>[</nowiki>]]
+111101111 || 134 || 92 || 5C || [[Backslash|\]]
+111111011 || 135 || 93 || 5D || [[Bracket|<nowiki>]</nowiki>]]
+1010111111 || 136 || 94 || 5E || [[Caret|^]]
+101101101 || 137 || 95 || 5F || [[Underscore|_]]
+1011011111 || 140 || 96 || 60 || [[Grave accent|`]]
+1011 || 141 || 97 || 61 || [[a]]
+1011111 || 142 || 98 || 62 || [[b]]
+101111 || 143 || 99 || 63 || [[c]]
+101101 || 144 || 100 || 64 || [[d]]
+11 || 145 || 101 || 65 || [[e]]
+111101 || 146 || 102 || 66 || [[f]]
+1011011 || 147 || 103 || 67 || [[g]]
+101011 || 150 || 104 || 68 || [[h]]
+1101 || 151 || 105 || 69 || [[i]]
+111101011 || 152 || 106 || 6A || [[j]]
+10111111 || 153 || 107 || 6B || [[k]]
+11011 || 154 || 108 || 6C || [[l]]
+111011 || 155 || 109 || 6D || [[m]]
+1111 || 156 || 110 || 6E || [[n]]
+111 || 157 || 111 || 6F || [[o]]
+111111 || 160 || 112 || 70 || [[p]]
+110111111 || 161 || 113 || 71 || [[q]]
+10101 || 162 || 114 || 72 || [[r]]
+10111 || 163 || 115 || 73 || [[s]]
+101 || 164 || 116 || 74 || [[t]]
+110111 || 165 || 117 || 75 || [[u]]
+1111011 || 166 || 118 || 76 || [[v]]
+1101011 || 167 || 119 || 77 || [[w]]
+11011111 || 170 || 120 || 78 || [[x]]
+1011101 || 171 || 121 || 79 || [[y]]
+111010101 || 172 || 122 || 7A || [[z]]
+1010110111 || 173 || 123 || 7B || [[Bracket|&#123;]]
+110111011 || 174 || 124 || 7C || [[Vertical bar|&#124;]]
+1010110101 || 175 || 125 || 7D || [[Bracket|&#125;]]
+1011010111 || 176 || 126 || 7E || [[Tilde|~]]
+1110110101 || 177 || 127 || 7F || DEL || Delete