#include <stdio.h> #define CK_ANSIC #define USHORT unsigned short #define ULONG unsigned long #define CONST const #define CHAR unsigned char /* ucsterm.c. Produce a table of Unicode Terminal Graphics. F. da Cruz, Columbia University, 2000. */ char *name[] = { "E100 NUL Ctrl Pic Null", "E101 SOH Ctrl Pic Start of Heading", "E102 STX Ctrl Pic Start of Text", "E103 ETX Ctrl Pic End of Text", "E104 EOT Ctrl Pic End of Transmission", "E105 ENQ Ctrl Pic Enquiry", "E106 ACK Ctrl Pic Acknowledge", "E107 BEL Ctrl Pic Bell", "E108 BS Ctrl Pic Backspace", "E109 HT Ctrl Pic Horizontal Tab", "E10A LF Ctrl Pic Line Feed", "E10B VT Ctrl Pic Vertical Tab", "E10C FF Ctrl Pic Form Feed", "E10D CR Ctrl Pic Carriage Return", "E10E SO Ctrl Pic Shift Out", "E10F SI Ctrl Pic Shift In", "E110 DLE Ctrl Pic Data Link Escape", "E111 DC1 Ctrl Pic Device Control 1", "E112 DC2 Ctrl Pic Device Control 2", "E113 DC3 Ctrl Pic Device Control 3", "E114 DC4 Ctrl Pic Device Control 4", "E115 NAK Ctrl Pic Negative Acknowledge", "E116 SYN Ctrl Pic Synchronous Idle", "E117 ETB Ctrl Pic End of Transmission Block", "E118 CAN Ctrl Pic Cancel", "E119 EM Ctrl Pic End of Medium", "E11A SUB Ctrl Pic Substitute", "E11B ESC Ctrl Pic Escape", "E11C FS Ctrl Pic Field Separator", "E11D GS Ctrl Pic Group Separator", "E11E RS Ctrl Pic Record Separator", "E11F US Ctrl Pic Unit Separator", "E120 (vacant)", "E121 (vacant)", "E122 BPH Ctrl Pic Break Permitted Here", "E123 NBH Ctrl Pic No Break Here", "E124 IND Ctrl Pic Index", "E125 NEL Ctrl Pic Next Line", "E126 SSA Ctrl Pic Start Selected Area", "E127 ESA Ctrl Pic End Selected Area", "E128 HTS Ctrl Pic Character Tabulation Set", "E129 HTJ Ctrl Pic Character Tabulation with Justification", "E12A VTS Ctrl Pic Line Tabulation Set", "E12B PLD Ctrl Pic Partial Line Forward", "E12C PLU Ctrl Pic Partial Line Backward", "E12D RI Ctrl Pic Reverse Line Feed", "E12E SS2 Ctrl Pic Single Shift 2", "E12F SS3 Ctrl Pic Single Shift 3", "E130 DCS Ctrl Pic Device Control String", "E131 PU1 Ctrl Pic Private Use 1", "E132 PU2 Ctrl Pic Private Use 2", "E133 STS Ctrl Pic Set Transmit State", "E134 CCH Ctrl Pic Cancel Character", "E135 MW Ctrl Pic Message Waiting", "E136 SPA Ctrl Pic Start Protected (Guarded) Area", "E137 EPA Ctrl Pic End Protected (Guarded) Area", "E138 SOS Ctrl Pic Start of String", "E139 (vacant)", "E13A SCI Ctrl Pic Single Character Introducer", "E13B CSI Ctrl Pic Control Sequence Introducer", "E13C ST Ctrl Pic String Terminator", "E13D OSC Ctrl Pic Operating System Command", "E13E PM Ctrl Pic Privacy Message", "E13F APC Ctrl Pic Application Program Command", "E140 PF Ctrl Pic Punch Off", "E141 PN Ctrl Pic Punch On", "E142 LC Ctrl Pic Lower Case", "E143 UC Ctrl Pic Upper Case", "E144 SMM Ctrl Pic Start of Manual Message", "E145 TM Ctrl Pic Tape Mark", "E146 RES Ctrl Pic Restore", "E147 IL Ctrl Pic Idle", "E148 CC Ctrl Pic Cursor Control", "E149 CU1 Ctrl Pic Customer Use 1", "E14A CU2 Ctrl Pic Customer Use 2", "E14B CU3 Ctrl Pic Customer Use 3", "E14C CU4 Ctrl Pic Customer Use 4", "E14D IFS Ctrl Pic Interchange File Separator", "E14E IGS Ctrl Pic Interchange Group Separator", "E14F IUS Ctrl Pic Interchange Unit Separator", "E150 DS Ctrl Pic Digit Select", "E151 SOS Ctrl Pic Start of Significance", "E152 BYP Ctrl Pic Bypass", "E153 SM Ctrl Pic Set Mode", "E154 (vacant)", "E155 (vacant)", "E156 (vacant)", "E157 (vacant)", "E158 (vacant)", "E159 (vacant)", "E15A (vacant)", "E15B (vacant)", "E15C (vacant)", "E15D (vacant)", "E15E (vacant)", "E15F (vacant)", "E160 VCS Vertical Channel Select", "E161 GE Graphics Escape", "E162 ENP Enable Presentation", "E163 IRS Interchange Record Separator", "E164 INP Inhibit Presentation", "E165 SA Set Attribute", "E166 FMT Format", "E167 TRN Transparent", "E168 SF Start Field", "E169 SFE Start Field Extended", "E16A SBA Set Buffer Address", "E16B MF Modify Field", "E16C PT Program Tab", "E16D RA Repeat to Address", "E16E EUA Erase to Unprotected Address", "E16F DUP Duplicate", "E170 FM Field Mark", "E171 EO Eight Ones", "E172 (vacant)", "E173 (vacant)", "E174 (vacant)", "E175 (vacant)", "E176 (vacant)", "E177 (vacant)", "E178 (vacant)", "E179 (vacant)", "E17A (vacant)", "E17B (vacant)", "E17C (vacant)", "E17D (vacant)", "E17E (vacant)", "E17F (vacant)", "E180 SP Ctrl Pic Space", "E181 DEL Ctrl Pic Delete", "E182 LS1 Ctrl Pic Locking Shift 1", "E183 LS0 Ctrl Pic Locking Shift 0", "E184 IS4 Ctrl Pic Information Separator 4", "E185 IS3 Ctrl Pic Information Separator 3", "E186 IS2 Ctrl Pic Information Separator 2", "E187 IS1 Ctrl Pic Information Separator 1", "E188 CL Ctrl Pic Cancel Line", "E189 BP Ctrl Pic DG Word Processing BP", "E18A BE Ctrl Pic DG Word Processing BE", "E18B FN Ctrl Pic DG Word Processing FN", "E18C FE Ctrl Pic DG Word Processing FE", "E18D HF Ctrl Pic DG Word Processing HF", "E18E Diagonal crosshatches", "E18F Picture of bell", "E190 (vacant)", "E191 (vacant)", "E192 (vacant)", "E193 (vacant)", "E194 (vacant)", "E195 (vacant)", "E196 (vacant)", "E197 (vacant)", "E198 (vacant)", "E199 (vacant)", "E19A (vacant)", "E19B (vacant)", "E19C (vacant)", "E19D (vacant)", "E19E (vacant)", "E19F (vacant)", "E1A0 Extensible left brace middle", "E1A1 Extensible left parenthesis bottom", "E1A2 Extensible left parenthesis top", "E1A3 Extensible left SB bottom", "E1A4 Extensible left SB top", "E1A5 Extensible right brace middle", "E1A6 Extensible UR or LL brace section", "E1A7 Extensible LR or UL brace section", "E1A8 Extensible right parenthesis bottom", "E1A9 Extensible right parenthesis top", "E1AA Extensible right SB bottom", "E1AB Extensible right SB top", "E1AC Summation symbol bottom", "E1AD Summation symbol top", "E1AE Right ceiling corner", "E1AF Right floor corner", "E1B0 Radical symbol, small", "E1B1 Radical symbol with stroke", "E1B2 Superscript Latin small letter i", "E1B3 Latin small letter a with underbar", "E1B4 Latin capital letter H with bar", "E1B5 Latin small letter h with bar", "E1B6 Latin capital letter L with dot", "E1B7 Latin small letter L with dot", "E1B8 Latin capital letter O with underbar", "E1B9 Latin small letter t with bar", "E1BA Latin small script letter t with bar", "E1BB Eng-like letter", "E1BC Eng-like letter, fatter", "E1BD Eng-like letter with vertical stroke", "E1BE Superscript almost-equal-to sign", "E1BF Superscript capital Greek letterSigma", "E1C0 Superscript infinity sign", "E1C1 Superscript proportional-to sign", "E1C2 (vacant)", "E1C3 (vacant)", "E1C4 (vacant)", "E1C5 (vacant)", "E1C6 (vacant)", "E1C7 (vacant)", "E1C8 (vacant)", "E1C9 (vacant)", "E1CA (vacant)", "E1CB (vacant)", "E1CC (vacant)", "E1CD (vacant)", "E1CE (vacant)", "E1CF (vacant)", "E1D0 L V box line, extensible", "E1D1 R V box line, extensible", "E1D2 UL Wedge", "E1D3 UR Wedge", "E1D4 LL Wedge", "E1D5 LR Wedge", "E1D6 H line - Scan 1", "E1D7 H line - Scan 3", "E1D8 (vacant)", "E1D9 H line - Scan 7", "E1DA H line - Scan 9", "E1DB Quadrant LL", "E1DC Quadrant LR", "E1DD Quadrant UL", "E1DE Quadrant UL and LL and LR", "E1DF Quadrant UL and LR", "E1E0 Quadrant UL and UR and LL", "E1E1 Quadrant UL and UR and LR", "E1E2 Quadrant UR", "E1E3 Quadrant UR and LL", "E1E4 Quadrant UR and LL and LR", "E1E5 Full black diamond", "E1E6 Black framus", "E1E7 Black framus + H center bar", "E1E8 White framus", "E1E9 White framus + H center bar", "E1EA R & L arrow to V center bar", "E1EB Up arrow to H center line", "E1EC R arrow to V center line", "E1ED L arrow to V center line", "E1EE Down arrow to H center line", "E1EF Box drawing double dash H", "E1F0 Reverse Question Mark", "E1F1 Box with X inside", "E1F2 Human stick figure with hat", "E1F3 Clock at 3:00", "E1F4 Overscore asterisk", "E1F5 Overscore semicolon", "E1F6 Padlock", "E1F7 (vacant)", "E1F8 (vacant)", "E1F9 (vacant)", "E1FA (vacant)", "E1FB (vacant)", "E1FC (vacant)", "E1FD (vacant)", "E1FE (vacant)", "E1FF (vacant)", "E200 Hex Byte 00", "E201 Hex Byte 01", "E202 Hex Byte 02", "E203 Hex Byte 03", "E204 Hex Byte 04", "E205 Hex Byte 05", "E206 Hex Byte 06", "E207 Hex Byte 07", "E208 Hex Byte 08", "E209 Hex Byte 09", "E20A Hex Byte 0A", "E20B Hex Byte 0B", "E20C Hex Byte 0C", "E20D Hex Byte 0D", "E20E Hex Byte 0E", "E20F Hex Byte 0F", "E210 Hex Byte 10", "E211 Hex Byte 11", "E212 Hex Byte 12", "E213 Hex Byte 13", "E214 Hex Byte 14", "E215 Hex Byte 15", "E216 Hex Byte 16", "E217 Hex Byte 17", "E218 Hex Byte 18", "E219 Hex Byte 19", "E21A Hex Byte 1A", "E21B Hex Byte 1B", "E21C Hex Byte 1C", "E21D Hex Byte 1D", "E21E Hex Byte 1E", "E21F Hex Byte 1F", "E220 Hex Byte 20", "E221 Hex Byte 21", "E222 Hex Byte 22", "E223 Hex Byte 23", "E224 Hex Byte 24", "E225 Hex Byte 25", "E226 Hex Byte 26", "E227 Hex Byte 27", "E228 Hex Byte 28", "E229 Hex Byte 29", "E22A Hex Byte 2A", "E22B Hex Byte 2B", "E22C Hex Byte 2C", "E22D Hex Byte 2D", "E22E Hex Byte 2E", "E22F Hex Byte 2F", "E230 Hex Byte 30", "E231 Hex Byte 31", "E232 Hex Byte 32", "E233 Hex Byte 33", "E234 Hex Byte 34", "E235 Hex Byte 35", "E236 Hex Byte 36", "E237 Hex Byte 37", "E238 Hex Byte 38", "E239 Hex Byte 39", "E23A Hex Byte 3A", "E23B Hex Byte 3B", "E23C Hex Byte 3C", "E23D Hex Byte 3D", "E23E Hex Byte 3E", "E23F Hex Byte 3F", "E240 Hex Byte 40", "E241 Hex Byte 41", "E242 Hex Byte 42", "E243 Hex Byte 43", "E244 Hex Byte 44", "E245 Hex Byte 45", "E246 Hex Byte 46", "E247 Hex Byte 47", "E248 Hex Byte 48", "E249 Hex Byte 49", "E24A Hex Byte 4A", "E24B Hex Byte 4B", "E24C Hex Byte 4C", "E24D Hex Byte 4D", "E24E Hex Byte 4E", "E24F Hex Byte 4F", "E250 Hex Byte 50", "E251 Hex Byte 51", "E252 Hex Byte 52", "E253 Hex Byte 53", "E254 Hex Byte 54", "E255 Hex Byte 55", "E256 Hex Byte 56", "E257 Hex Byte 57", "E258 Hex Byte 58", "E259 Hex Byte 59", "E25A Hex Byte 5A", "E25B Hex Byte 5B", "E25C Hex Byte 5C", "E25D Hex Byte 5D", "E25E Hex Byte 5E", "E25F Hex Byte 5F", "E260 Hex Byte 60", "E261 Hex Byte 61", "E262 Hex Byte 62", "E263 Hex Byte 63", "E264 Hex Byte 64", "E265 Hex Byte 65", "E266 Hex Byte 66", "E267 Hex Byte 67", "E268 Hex Byte 68", "E269 Hex Byte 69", "E26A Hex Byte 6A", "E26B Hex Byte 6B", "E26C Hex Byte 6C", "E26D Hex Byte 6D", "E26E Hex Byte 6E", "E26F Hex Byte 6F", "E270 Hex Byte 70", "E271 Hex Byte 71", "E272 Hex Byte 72", "E273 Hex Byte 73", "E274 Hex Byte 74", "E275 Hex Byte 75", "E276 Hex Byte 76", "E277 Hex Byte 77", "E278 Hex Byte 78", "E279 Hex Byte 79", "E27A Hex Byte 7A", "E27B Hex Byte 7B", "E27C Hex Byte 7C", "E27D Hex Byte 7D", "E27E Hex Byte 7E", "E27F Hex Byte 7F", "E280 Hex Byte 80", "E281 Hex Byte 81", "E282 Hex Byte 82", "E283 Hex Byte 83", "E284 Hex Byte 84", "E285 Hex Byte 85", "E286 Hex Byte 86", "E287 Hex Byte 87", "E288 Hex Byte 88", "E289 Hex Byte 89", "E28A Hex Byte 8A", "E28B Hex Byte 8B", "E28C Hex Byte 8C", "E28D Hex Byte 8D", "E28E Hex Byte 8E", "E28F Hex Byte 8F", "E290 Hex Byte 90", "E291 Hex Byte 91", "E292 Hex Byte 92", "E293 Hex Byte 93", "E294 Hex Byte 94", "E295 Hex Byte 95", "E296 Hex Byte 96", "E297 Hex Byte 97", "E298 Hex Byte 98", "E299 Hex Byte 99", "E29A Hex Byte 9A", "E29B Hex Byte 9B", "E29C Hex Byte 9C", "E29D Hex Byte 9D", "E29E Hex Byte 9E", "E29F Hex Byte 9F", "E2A0 Hex Byte A0", "E2A1 Hex Byte A1", "E2A2 Hex Byte A2", "E2A3 Hex Byte A3", "E2A4 Hex Byte A4", "E2A5 Hex Byte A5", "E2A6 Hex Byte A6", "E2A7 Hex Byte A7", "E2A8 Hex Byte A8", "E2A9 Hex Byte A9", "E2AA Hex Byte AA", "E2AB Hex Byte AB", "E2AC Hex Byte AC", "E2AD Hex Byte AD", "E2AE Hex Byte AE", "E2AF Hex Byte AF", "E2B0 Hex Byte B0", "E2B1 Hex Byte B1", "E2B2 Hex Byte B2", "E2B3 Hex Byte B3", "E2B4 Hex Byte B4", "E2B5 Hex Byte B5", "E2B6 Hex Byte B6", "E2B7 Hex Byte B7", "E2B8 Hex Byte B8", "E2B9 Hex Byte B9", "E2BA Hex Byte BA", "E2BB Hex Byte BB", "E2BC Hex Byte BC", "E2BD Hex Byte BD", "E2BE Hex Byte BE", "E2BF Hex Byte BF", "E2C0 Hex Byte C0", "E2C1 Hex Byte C1", "E2C2 Hex Byte C2", "E2C3 Hex Byte C3", "E2C4 Hex Byte C4", "E2C5 Hex Byte C5", "E2C6 Hex Byte C6", "E2C7 Hex Byte C7", "E2C8 Hex Byte C8", "E2C9 Hex Byte C9", "E2CA Hex Byte CA", "E2CB Hex Byte CB", "E2CC Hex Byte CC", "E2CD Hex Byte CD", "E2CE Hex Byte CE", "E2CF Hex Byte CF", "E2D0 Hex Byte D0", "E2D1 Hex Byte D1", "E2D2 Hex Byte D2", "E2D3 Hex Byte D3", "E2D4 Hex Byte D4", "E2D5 Hex Byte D5", "E2D6 Hex Byte D6", "E2D7 Hex Byte D7", "E2D8 Hex Byte D8", "E2D9 Hex Byte D9", "E2DA Hex Byte DA", "E2DB Hex Byte DB", "E2DC Hex Byte DC", "E2DD Hex Byte DD", "E2DE Hex Byte DE", "E2DF Hex Byte DF", "E2E0 Hex Byte E0", "E2E1 Hex Byte E1", "E2E2 Hex Byte E2", "E2E3 Hex Byte E3", "E2E4 Hex Byte E4", "E2E5 Hex Byte E5", "E2E6 Hex Byte E6", "E2E7 Hex Byte E7", "E2E8 Hex Byte E8", "E2E9 Hex Byte E9", "E2EA Hex Byte EA", "E2EB Hex Byte EB", "E2EC Hex Byte EC", "E2ED Hex Byte ED", "E2EE Hex Byte EE", "E2EF Hex Byte EF", "E2F0 Hex Byte F0", "E2F1 Hex Byte F1", "E2F2 Hex Byte F2", "E2F3 Hex Byte F3", "E2F4 Hex Byte F4", "E2F5 Hex Byte F5", "E2F6 Hex Byte F6", "E2F7 Hex Byte F7", "E2F8 Hex Byte F8", "E2F9 Hex Byte F9", "E2FA Hex Byte FA", "E2FB Hex Byte FB", "E2FC Hex Byte FC", "E2FD Hex Byte FD", "E2FE Hex Byte FE", "E2FF Hex Byte FF" }; CHAR firstByteMark[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC}; int #ifdef CK_ANSIC ucs2_to_utf8(USHORT ucs2, CHAR ** utf8) #else ucs2_to_utf8(ucs2, utf8) USHORT ucs2; CHAR ** utf8; #endif /* CK_ANSIC */ { static CHAR utf8return[8]={0,0,0,0,0,0,0,0}; register CONST ULONG byteMask = 0xBF; register CONST ULONG byteMark = 0x80; int utf8len = 0; int i = 0; if (ucs2 < 0x80) { utf8len = 1; } else if (ucs2 < 0x800) { utf8len = 2; } else #ifdef DO_UCS4 /* This is always true for UCS-2 but would be needed for UCS-4*/ /* When ucs2 is USHORT this gives compiler warnings. */ if (ucs2 <= 0xffff) #endif /* DO_UCS4 */ { utf8len = 3; } #ifdef DO_UCS4 /* The following would be for UCS-4 */ else if (ucs2 < 0x200000) { utf8len = 4; } else if (ucs2 < 0x4000000) { utf8len = 5; } else if (ucs2 <= #ifdef CK_ANSIC 0x7FFFFFFFUL /* (doesn't really need the "U") */ #else 0x7FFFFFFFL #endif /* CK_ANSIC */ ) { /* 31 bits = max for UCS4 */ utf8len = 6; } else { utf8len = 2; ucs2 = 0xFFFD; /* Replacement for invalid char */ } #endif /* DO_UCS4 */ i = utf8len; /* index into utf8return */ utf8return[i--] = 0; /* Null terminate the string */ switch (utf8len) { /* code falls through cases! */ case 6: utf8return[i--] = (ucs2 | byteMark) & byteMask; ucs2 >>= 6; case 5: utf8return[i--] = (ucs2 | byteMark) & byteMask; ucs2 >>= 6; case 4: utf8return[i--] = (ucs2 | byteMark) & byteMask; ucs2 >>= 6; case 3: utf8return[i--] = (ucs2 | byteMark) & byteMask; ucs2 >>= 6; case 2: utf8return[i--] = (ucs2 | byteMark) & byteMask; ucs2 >>= 6; case 1: utf8return[i--] = ucs2 | firstByteMark[utf8len]; } *utf8 = utf8return; return(utf8len); } /* #define TEST */ int main() { USHORT x, k; int i, n; CHAR * buf = NULL; printf("UCS Terminal Private Use Area U+E100-E2FF\n"); printf("Char Hex Ctrl Name\n"); for (x = 0; x < 512; x++) { k = (unsigned)((unsigned)0xE100 + x); n = ucs2_to_utf8(k,&buf); putchar('['); for (i = 0; i < n; i++) putchar(buf[i]); putchar(']'); printf(" %s\n",name[x]); } }