home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / charsets / ucsterm.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  19KB  |  612 lines

  1. #include <stdio.h>
  2.  
  3. #define CK_ANSIC
  4. #define USHORT unsigned short
  5. #define ULONG unsigned long
  6. #define CONST const
  7. #define CHAR unsigned char
  8.  
  9. /*
  10.   ucsterm.c.  Produce a table of Unicode Terminal Graphics.
  11.   F. da Cruz, Columbia University, 2000.
  12. */
  13. char *name[] = {
  14.   "E100  NUL   Ctrl Pic Null",
  15.   "E101  SOH   Ctrl Pic Start of Heading",
  16.   "E102  STX   Ctrl Pic Start of Text",
  17.   "E103  ETX   Ctrl Pic End of Text",
  18.   "E104  EOT   Ctrl Pic End of Transmission",
  19.   "E105  ENQ   Ctrl Pic Enquiry",
  20.   "E106  ACK   Ctrl Pic Acknowledge",
  21.   "E107  BEL   Ctrl Pic Bell",
  22.   "E108  BS    Ctrl Pic Backspace",
  23.   "E109  HT    Ctrl Pic Horizontal Tab",
  24.   "E10A  LF    Ctrl Pic Line Feed",
  25.   "E10B  VT    Ctrl Pic Vertical Tab",
  26.   "E10C  FF    Ctrl Pic Form Feed",
  27.   "E10D  CR    Ctrl Pic Carriage Return",
  28.   "E10E  SO    Ctrl Pic Shift Out",
  29.   "E10F  SI    Ctrl Pic Shift In",
  30.   "E110  DLE   Ctrl Pic Data Link Escape",
  31.   "E111  DC1   Ctrl Pic Device Control 1",
  32.   "E112  DC2   Ctrl Pic Device Control 2",
  33.   "E113  DC3   Ctrl Pic Device Control 3",
  34.   "E114  DC4   Ctrl Pic Device Control 4",
  35.   "E115  NAK   Ctrl Pic Negative Acknowledge",
  36.   "E116  SYN   Ctrl Pic Synchronous Idle",
  37.   "E117  ETB   Ctrl Pic End of Transmission Block",
  38.   "E118  CAN   Ctrl Pic Cancel",
  39.   "E119  EM    Ctrl Pic End of Medium",
  40.   "E11A  SUB   Ctrl Pic Substitute",
  41.   "E11B  ESC   Ctrl Pic Escape",
  42.   "E11C  FS    Ctrl Pic Field Separator",
  43.   "E11D  GS    Ctrl Pic Group Separator",
  44.   "E11E  RS    Ctrl Pic Record Separator",
  45.   "E11F  US    Ctrl Pic Unit Separator",
  46.   "E120        (vacant)",
  47.   "E121        (vacant)",
  48.   "E122  BPH   Ctrl Pic Break Permitted Here",
  49.   "E123  NBH   Ctrl Pic No Break Here",
  50.   "E124  IND   Ctrl Pic Index",
  51.   "E125  NEL   Ctrl Pic Next Line",
  52.   "E126  SSA   Ctrl Pic Start Selected Area",
  53.   "E127  ESA   Ctrl Pic End Selected Area",
  54.   "E128  HTS   Ctrl Pic Character Tabulation Set",
  55.   "E129  HTJ   Ctrl Pic Character Tabulation with Justification",
  56.   "E12A  VTS   Ctrl Pic Line Tabulation Set",
  57.   "E12B  PLD   Ctrl Pic Partial Line Forward",
  58.   "E12C  PLU   Ctrl Pic Partial Line Backward",
  59.   "E12D  RI    Ctrl Pic Reverse Line Feed",
  60.   "E12E  SS2   Ctrl Pic Single Shift 2",
  61.   "E12F  SS3   Ctrl Pic Single Shift 3",
  62.   "E130  DCS   Ctrl Pic Device Control String",
  63.   "E131  PU1   Ctrl Pic Private Use 1",
  64.   "E132  PU2   Ctrl Pic Private Use 2",
  65.   "E133  STS   Ctrl Pic Set Transmit State",
  66.   "E134  CCH   Ctrl Pic Cancel Character",
  67.   "E135  MW    Ctrl Pic Message Waiting",
  68.   "E136  SPA   Ctrl Pic Start Protected (Guarded) Area",
  69.   "E137  EPA   Ctrl Pic End Protected (Guarded) Area",
  70.   "E138  SOS   Ctrl Pic Start of String",
  71.   "E139        (vacant)",
  72.   "E13A  SCI   Ctrl Pic Single Character Introducer",
  73.   "E13B  CSI   Ctrl Pic Control Sequence Introducer",
  74.   "E13C  ST    Ctrl Pic String Terminator",
  75.   "E13D  OSC   Ctrl Pic Operating System Command",
  76.   "E13E  PM    Ctrl Pic Privacy Message",
  77.   "E13F  APC   Ctrl Pic Application Program Command",
  78.   "E140  PF    Ctrl Pic Punch Off",
  79.   "E141  PN    Ctrl Pic Punch On",
  80.   "E142  LC    Ctrl Pic Lower Case",
  81.   "E143  UC    Ctrl Pic Upper Case",
  82.   "E144  SMM   Ctrl Pic Start of Manual Message",
  83.   "E145  TM    Ctrl Pic Tape Mark",
  84.   "E146  RES   Ctrl Pic Restore",
  85.   "E147  IL    Ctrl Pic Idle",
  86.   "E148  CC    Ctrl Pic Cursor Control",
  87.   "E149  CU1   Ctrl Pic Customer Use 1",
  88.   "E14A  CU2   Ctrl Pic Customer Use 2",
  89.   "E14B  CU3   Ctrl Pic Customer Use 3",
  90.   "E14C  CU4   Ctrl Pic Customer Use 4",
  91.   "E14D  IFS   Ctrl Pic Interchange File Separator",
  92.   "E14E  IGS   Ctrl Pic Interchange Group Separator",
  93.   "E14F  IUS   Ctrl Pic Interchange Unit Separator",
  94.   "E150  DS    Ctrl Pic Digit Select",
  95.   "E151  SOS   Ctrl Pic Start of Significance",
  96.   "E152  BYP   Ctrl Pic Bypass",
  97.   "E153  SM    Ctrl Pic Set Mode",
  98.   "E154        (vacant)",
  99.   "E155        (vacant)",
  100.   "E156        (vacant)",
  101.   "E157        (vacant)",
  102.   "E158        (vacant)",
  103.   "E159        (vacant)",
  104.   "E15A        (vacant)",
  105.   "E15B        (vacant)",
  106.   "E15C        (vacant)",
  107.   "E15D        (vacant)",
  108.   "E15E        (vacant)",
  109.   "E15F        (vacant)",
  110.   "E160  VCS   Vertical Channel Select",
  111.   "E161  GE    Graphics Escape",
  112.   "E162  ENP   Enable Presentation",
  113.   "E163  IRS   Interchange Record Separator",
  114.   "E164  INP   Inhibit Presentation",
  115.   "E165  SA    Set Attribute",
  116.   "E166  FMT   Format",
  117.   "E167  TRN   Transparent",
  118.   "E168  SF    Start Field",
  119.   "E169  SFE   Start Field Extended",
  120.   "E16A  SBA   Set Buffer Address",
  121.   "E16B  MF    Modify Field",
  122.   "E16C  PT    Program Tab",
  123.   "E16D  RA    Repeat to Address",
  124.   "E16E  EUA   Erase to Unprotected Address",
  125.   "E16F  DUP   Duplicate",
  126.   "E170  FM    Field Mark",
  127.   "E171  EO    Eight Ones",
  128.   "E172        (vacant)",
  129.   "E173        (vacant)",
  130.   "E174        (vacant)",
  131.   "E175        (vacant)",
  132.   "E176        (vacant)",
  133.   "E177        (vacant)",
  134.   "E178        (vacant)",
  135.   "E179        (vacant)",
  136.   "E17A        (vacant)",
  137.   "E17B        (vacant)",
  138.   "E17C        (vacant)",
  139.   "E17D        (vacant)",
  140.   "E17E        (vacant)",
  141.   "E17F        (vacant)",
  142.   "E180  SP    Ctrl Pic Space",
  143.   "E181  DEL   Ctrl Pic Delete",
  144.   "E182  LS1   Ctrl Pic Locking Shift 1",
  145.   "E183  LS0   Ctrl Pic Locking Shift 0",
  146.   "E184  IS4   Ctrl Pic Information Separator 4",
  147.   "E185  IS3   Ctrl Pic Information Separator 3",
  148.   "E186  IS2   Ctrl Pic Information Separator 2",
  149.   "E187  IS1   Ctrl Pic Information Separator 1",
  150.   "E188  CL    Ctrl Pic Cancel Line",
  151.   "E189  BP    Ctrl Pic DG Word Processing BP",
  152.   "E18A  BE    Ctrl Pic DG Word Processing BE",
  153.   "E18B  FN    Ctrl Pic DG Word Processing FN",
  154.   "E18C  FE    Ctrl Pic DG Word Processing FE",
  155.   "E18D  HF    Ctrl Pic DG Word Processing HF",
  156.   "E18E        Diagonal crosshatches",
  157.   "E18F        Picture of bell",
  158.   "E190        (vacant)",
  159.   "E191        (vacant)",
  160.   "E192        (vacant)",
  161.   "E193        (vacant)",
  162.   "E194        (vacant)",
  163.   "E195        (vacant)",
  164.   "E196        (vacant)",
  165.   "E197        (vacant)",
  166.   "E198        (vacant)",
  167.   "E199        (vacant)",
  168.   "E19A        (vacant)",
  169.   "E19B        (vacant)",
  170.   "E19C        (vacant)",
  171.   "E19D        (vacant)",
  172.   "E19E        (vacant)",
  173.   "E19F        (vacant)",
  174.   "E1A0        Extensible left brace middle",
  175.   "E1A1        Extensible left parenthesis bottom",
  176.   "E1A2        Extensible left parenthesis top",
  177.   "E1A3        Extensible left SB bottom",
  178.   "E1A4        Extensible left SB top",
  179.   "E1A5        Extensible right brace middle",
  180.   "E1A6        Extensible UR or LL brace section",
  181.   "E1A7        Extensible LR or UL brace section",
  182.   "E1A8        Extensible right parenthesis bottom",
  183.   "E1A9        Extensible right parenthesis top",
  184.   "E1AA        Extensible right SB bottom",
  185.   "E1AB        Extensible right SB top",
  186.   "E1AC        Summation symbol bottom",
  187.   "E1AD        Summation symbol top",
  188.   "E1AE        Right ceiling corner",
  189.   "E1AF        Right floor corner",
  190.   "E1B0        Radical symbol, small",
  191.   "E1B1        Radical symbol with stroke",
  192.   "E1B2        Superscript Latin small letter i",
  193.   "E1B3        Latin small letter a with underbar",
  194.   "E1B4        Latin capital letter H with bar",
  195.   "E1B5        Latin small letter h with bar",
  196.   "E1B6        Latin capital letter L with dot",
  197.   "E1B7        Latin small letter L with dot",
  198.   "E1B8        Latin capital letter O with underbar",
  199.   "E1B9        Latin small letter t with bar",
  200.   "E1BA        Latin small script letter t with bar",
  201.   "E1BB        Eng-like letter",
  202.   "E1BC        Eng-like letter, fatter",
  203.   "E1BD        Eng-like letter with vertical stroke",
  204.   "E1BE        Superscript almost-equal-to sign",
  205.   "E1BF        Superscript capital Greek letterSigma",
  206.   "E1C0        Superscript infinity sign",
  207.   "E1C1        Superscript proportional-to sign",
  208.   "E1C2        (vacant)",
  209.   "E1C3        (vacant)",
  210.   "E1C4        (vacant)",
  211.   "E1C5        (vacant)",
  212.   "E1C6        (vacant)",
  213.   "E1C7        (vacant)",
  214.   "E1C8        (vacant)",
  215.   "E1C9        (vacant)",
  216.   "E1CA        (vacant)",
  217.   "E1CB        (vacant)",
  218.   "E1CC        (vacant)",
  219.   "E1CD        (vacant)",
  220.   "E1CE        (vacant)",
  221.   "E1CF        (vacant)",
  222.   "E1D0        L V box line, extensible",
  223.   "E1D1        R V box line, extensible",
  224.   "E1D2        UL Wedge",
  225.   "E1D3        UR Wedge",
  226.   "E1D4        LL Wedge",
  227.   "E1D5        LR Wedge",
  228.   "E1D6        H line - Scan 1",
  229.   "E1D7        H line - Scan 3",
  230.   "E1D8        (vacant)",
  231.   "E1D9        H line - Scan 7",
  232.   "E1DA        H line - Scan 9",
  233.   "E1DB        Quadrant LL",
  234.   "E1DC        Quadrant LR",
  235.   "E1DD        Quadrant UL",
  236.   "E1DE        Quadrant UL and LL and LR",
  237.   "E1DF        Quadrant UL and LR",
  238.   "E1E0        Quadrant UL and UR and LL",
  239.   "E1E1        Quadrant UL and UR and LR",
  240.   "E1E2        Quadrant UR",
  241.   "E1E3        Quadrant UR and LL",
  242.   "E1E4        Quadrant UR and LL and LR",
  243.   "E1E5        Full black diamond",
  244.   "E1E6        Black framus",
  245.   "E1E7        Black framus + H center bar",
  246.   "E1E8        White framus",
  247.   "E1E9        White framus + H center bar",
  248.   "E1EA        R & L arrow to V center bar",
  249.   "E1EB        Up arrow to H center line",
  250.   "E1EC        R arrow to V center line",
  251.   "E1ED        L arrow to V center line",
  252.   "E1EE        Down arrow to H center line",
  253.   "E1EF        Box drawing double dash H",
  254.   "E1F0        Reverse Question Mark",
  255.   "E1F1        Box with X inside",
  256.   "E1F2        Human stick figure with hat",
  257.   "E1F3        Clock at 3:00",
  258.   "E1F4        Overscore asterisk",
  259.   "E1F5        Overscore semicolon",
  260.   "E1F6        Padlock",
  261.   "E1F7        (vacant)",
  262.   "E1F8        (vacant)",
  263.   "E1F9        (vacant)",
  264.   "E1FA        (vacant)",
  265.   "E1FB        (vacant)",
  266.   "E1FC        (vacant)",
  267.   "E1FD        (vacant)",
  268.   "E1FE        (vacant)",
  269.   "E1FF        (vacant)",
  270.   "E200        Hex Byte 00",
  271.   "E201        Hex Byte 01",
  272.   "E202        Hex Byte 02",
  273.   "E203        Hex Byte 03",
  274.   "E204        Hex Byte 04",
  275.   "E205        Hex Byte 05",
  276.   "E206        Hex Byte 06",
  277.   "E207        Hex Byte 07",
  278.   "E208        Hex Byte 08",
  279.   "E209        Hex Byte 09",
  280.   "E20A        Hex Byte 0A",
  281.   "E20B        Hex Byte 0B",
  282.   "E20C        Hex Byte 0C",
  283.   "E20D        Hex Byte 0D",
  284.   "E20E        Hex Byte 0E",
  285.   "E20F        Hex Byte 0F",
  286.   "E210        Hex Byte 10",
  287.   "E211        Hex Byte 11",
  288.   "E212        Hex Byte 12",
  289.   "E213        Hex Byte 13",
  290.   "E214        Hex Byte 14",
  291.   "E215        Hex Byte 15",
  292.   "E216        Hex Byte 16",
  293.   "E217        Hex Byte 17",
  294.   "E218        Hex Byte 18",
  295.   "E219        Hex Byte 19",
  296.   "E21A        Hex Byte 1A",
  297.   "E21B        Hex Byte 1B",
  298.   "E21C        Hex Byte 1C",
  299.   "E21D        Hex Byte 1D",
  300.   "E21E        Hex Byte 1E",
  301.   "E21F        Hex Byte 1F",
  302.   "E220        Hex Byte 20",
  303.   "E221        Hex Byte 21",
  304.   "E222        Hex Byte 22",
  305.   "E223        Hex Byte 23",
  306.   "E224        Hex Byte 24",
  307.   "E225        Hex Byte 25",
  308.   "E226        Hex Byte 26",
  309.   "E227        Hex Byte 27",
  310.   "E228        Hex Byte 28",
  311.   "E229        Hex Byte 29",
  312.   "E22A        Hex Byte 2A",
  313.   "E22B        Hex Byte 2B",
  314.   "E22C        Hex Byte 2C",
  315.   "E22D        Hex Byte 2D",
  316.   "E22E        Hex Byte 2E",
  317.   "E22F        Hex Byte 2F",
  318.   "E230        Hex Byte 30",
  319.   "E231        Hex Byte 31",
  320.   "E232        Hex Byte 32",
  321.   "E233        Hex Byte 33",
  322.   "E234        Hex Byte 34",
  323.   "E235        Hex Byte 35",
  324.   "E236        Hex Byte 36",
  325.   "E237        Hex Byte 37",
  326.   "E238        Hex Byte 38",
  327.   "E239        Hex Byte 39",
  328.   "E23A        Hex Byte 3A",
  329.   "E23B        Hex Byte 3B",
  330.   "E23C        Hex Byte 3C",
  331.   "E23D        Hex Byte 3D",
  332.   "E23E        Hex Byte 3E",
  333.   "E23F        Hex Byte 3F",
  334.   "E240        Hex Byte 40",
  335.   "E241        Hex Byte 41",
  336.   "E242        Hex Byte 42",
  337.   "E243        Hex Byte 43",
  338.   "E244        Hex Byte 44",
  339.   "E245        Hex Byte 45",
  340.   "E246        Hex Byte 46",
  341.   "E247        Hex Byte 47",
  342.   "E248        Hex Byte 48",
  343.   "E249        Hex Byte 49",
  344.   "E24A        Hex Byte 4A",
  345.   "E24B        Hex Byte 4B",
  346.   "E24C        Hex Byte 4C",
  347.   "E24D        Hex Byte 4D",
  348.   "E24E        Hex Byte 4E",
  349.   "E24F        Hex Byte 4F",
  350.   "E250        Hex Byte 50",
  351.   "E251        Hex Byte 51",
  352.   "E252        Hex Byte 52",
  353.   "E253        Hex Byte 53",
  354.   "E254        Hex Byte 54",
  355.   "E255        Hex Byte 55",
  356.   "E256        Hex Byte 56",
  357.   "E257        Hex Byte 57",
  358.   "E258        Hex Byte 58",
  359.   "E259        Hex Byte 59",
  360.   "E25A        Hex Byte 5A",
  361.   "E25B        Hex Byte 5B",
  362.   "E25C        Hex Byte 5C",
  363.   "E25D        Hex Byte 5D",
  364.   "E25E        Hex Byte 5E",
  365.   "E25F        Hex Byte 5F",
  366.   "E260        Hex Byte 60",
  367.   "E261        Hex Byte 61",
  368.   "E262        Hex Byte 62",
  369.   "E263        Hex Byte 63",
  370.   "E264        Hex Byte 64",
  371.   "E265        Hex Byte 65",
  372.   "E266        Hex Byte 66",
  373.   "E267        Hex Byte 67",
  374.   "E268        Hex Byte 68",
  375.   "E269        Hex Byte 69",
  376.   "E26A        Hex Byte 6A",
  377.   "E26B        Hex Byte 6B",
  378.   "E26C        Hex Byte 6C",
  379.   "E26D        Hex Byte 6D",
  380.   "E26E        Hex Byte 6E",
  381.   "E26F        Hex Byte 6F",
  382.   "E270        Hex Byte 70",
  383.   "E271        Hex Byte 71",
  384.   "E272        Hex Byte 72",
  385.   "E273        Hex Byte 73",
  386.   "E274        Hex Byte 74",
  387.   "E275        Hex Byte 75",
  388.   "E276        Hex Byte 76",
  389.   "E277        Hex Byte 77",
  390.   "E278        Hex Byte 78",
  391.   "E279        Hex Byte 79",
  392.   "E27A        Hex Byte 7A",
  393.   "E27B        Hex Byte 7B",
  394.   "E27C        Hex Byte 7C",
  395.   "E27D        Hex Byte 7D",
  396.   "E27E        Hex Byte 7E",
  397.   "E27F        Hex Byte 7F",
  398.   "E280        Hex Byte 80",
  399.   "E281        Hex Byte 81",
  400.   "E282        Hex Byte 82",
  401.   "E283        Hex Byte 83",
  402.   "E284        Hex Byte 84",
  403.   "E285        Hex Byte 85",
  404.   "E286        Hex Byte 86",
  405.   "E287        Hex Byte 87",
  406.   "E288        Hex Byte 88",
  407.   "E289        Hex Byte 89",
  408.   "E28A        Hex Byte 8A",
  409.   "E28B        Hex Byte 8B",
  410.   "E28C        Hex Byte 8C",
  411.   "E28D        Hex Byte 8D",
  412.   "E28E        Hex Byte 8E",
  413.   "E28F        Hex Byte 8F",
  414.   "E290        Hex Byte 90",
  415.   "E291        Hex Byte 91",
  416.   "E292        Hex Byte 92",
  417.   "E293        Hex Byte 93",
  418.   "E294        Hex Byte 94",
  419.   "E295        Hex Byte 95",
  420.   "E296        Hex Byte 96",
  421.   "E297        Hex Byte 97",
  422.   "E298        Hex Byte 98",
  423.   "E299        Hex Byte 99",
  424.   "E29A        Hex Byte 9A",
  425.   "E29B        Hex Byte 9B",
  426.   "E29C        Hex Byte 9C",
  427.   "E29D        Hex Byte 9D",
  428.   "E29E        Hex Byte 9E",
  429.   "E29F        Hex Byte 9F",
  430.   "E2A0        Hex Byte A0",
  431.   "E2A1        Hex Byte A1",
  432.   "E2A2        Hex Byte A2",
  433.   "E2A3        Hex Byte A3",
  434.   "E2A4        Hex Byte A4",
  435.   "E2A5        Hex Byte A5",
  436.   "E2A6        Hex Byte A6",
  437.   "E2A7        Hex Byte A7",
  438.   "E2A8        Hex Byte A8",
  439.   "E2A9        Hex Byte A9",
  440.   "E2AA        Hex Byte AA",
  441.   "E2AB        Hex Byte AB",
  442.   "E2AC        Hex Byte AC",
  443.   "E2AD        Hex Byte AD",
  444.   "E2AE        Hex Byte AE",
  445.   "E2AF        Hex Byte AF",
  446.   "E2B0        Hex Byte B0",
  447.   "E2B1        Hex Byte B1",
  448.   "E2B2        Hex Byte B2",
  449.   "E2B3        Hex Byte B3",
  450.   "E2B4        Hex Byte B4",
  451.   "E2B5        Hex Byte B5",
  452.   "E2B6        Hex Byte B6",
  453.   "E2B7        Hex Byte B7",
  454.   "E2B8        Hex Byte B8",
  455.   "E2B9        Hex Byte B9",
  456.   "E2BA        Hex Byte BA",
  457.   "E2BB        Hex Byte BB",
  458.   "E2BC        Hex Byte BC",
  459.   "E2BD        Hex Byte BD",
  460.   "E2BE        Hex Byte BE",
  461.   "E2BF        Hex Byte BF",
  462.   "E2C0        Hex Byte C0",
  463.   "E2C1        Hex Byte C1",
  464.   "E2C2        Hex Byte C2",
  465.   "E2C3        Hex Byte C3",
  466.   "E2C4        Hex Byte C4",
  467.   "E2C5        Hex Byte C5",
  468.   "E2C6        Hex Byte C6",
  469.   "E2C7        Hex Byte C7",
  470.   "E2C8        Hex Byte C8",
  471.   "E2C9        Hex Byte C9",
  472.   "E2CA        Hex Byte CA",
  473.   "E2CB        Hex Byte CB",
  474.   "E2CC        Hex Byte CC",
  475.   "E2CD        Hex Byte CD",
  476.   "E2CE        Hex Byte CE",
  477.   "E2CF        Hex Byte CF",
  478.   "E2D0        Hex Byte D0",
  479.   "E2D1        Hex Byte D1",
  480.   "E2D2        Hex Byte D2",
  481.   "E2D3        Hex Byte D3",
  482.   "E2D4        Hex Byte D4",
  483.   "E2D5        Hex Byte D5",
  484.   "E2D6        Hex Byte D6",
  485.   "E2D7        Hex Byte D7",
  486.   "E2D8        Hex Byte D8",
  487.   "E2D9        Hex Byte D9",
  488.   "E2DA        Hex Byte DA",
  489.   "E2DB        Hex Byte DB",
  490.   "E2DC        Hex Byte DC",
  491.   "E2DD        Hex Byte DD",
  492.   "E2DE        Hex Byte DE",
  493.   "E2DF        Hex Byte DF",
  494.   "E2E0        Hex Byte E0",
  495.   "E2E1        Hex Byte E1",
  496.   "E2E2        Hex Byte E2",
  497.   "E2E3        Hex Byte E3",
  498.   "E2E4        Hex Byte E4",
  499.   "E2E5        Hex Byte E5",
  500.   "E2E6        Hex Byte E6",
  501.   "E2E7        Hex Byte E7",
  502.   "E2E8        Hex Byte E8",
  503.   "E2E9        Hex Byte E9",
  504.   "E2EA        Hex Byte EA",
  505.   "E2EB        Hex Byte EB",
  506.   "E2EC        Hex Byte EC",
  507.   "E2ED        Hex Byte ED",
  508.   "E2EE        Hex Byte EE",
  509.   "E2EF        Hex Byte EF",
  510.   "E2F0        Hex Byte F0",
  511.   "E2F1        Hex Byte F1",
  512.   "E2F2        Hex Byte F2",
  513.   "E2F3        Hex Byte F3",
  514.   "E2F4        Hex Byte F4",
  515.   "E2F5        Hex Byte F5",
  516.   "E2F6        Hex Byte F6",
  517.   "E2F7        Hex Byte F7",
  518.   "E2F8        Hex Byte F8",
  519.   "E2F9        Hex Byte F9",
  520.   "E2FA        Hex Byte FA",
  521.   "E2FB        Hex Byte FB",
  522.   "E2FC        Hex Byte FC",
  523.   "E2FD        Hex Byte FD",
  524.   "E2FE        Hex Byte FE",
  525.   "E2FF        Hex Byte FF"
  526. };
  527.  
  528. CHAR firstByteMark[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC};
  529.  
  530. int
  531. #ifdef CK_ANSIC
  532. ucs2_to_utf8(USHORT ucs2, CHAR ** utf8)
  533. #else
  534. ucs2_to_utf8(ucs2, utf8) USHORT ucs2; CHAR ** utf8;
  535. #endif /* CK_ANSIC */
  536. {
  537.     static CHAR utf8return[8]={0,0,0,0,0,0,0,0};
  538.     register CONST ULONG byteMask = 0xBF;
  539.     register CONST ULONG byteMark = 0x80;
  540.     int utf8len = 0;
  541.     int i = 0;
  542.  
  543.     if (ucs2 < 0x80) {
  544.         utf8len = 1;
  545.     } else if (ucs2 < 0x800) {
  546.         utf8len = 2;
  547.     } else
  548. #ifdef DO_UCS4
  549.       /* This is always true for UCS-2 but would be needed for UCS-4*/
  550.       /* When ucs2 is USHORT this gives compiler warnings. */
  551.       if (ucs2 <= 0xffff)
  552. #endif /* DO_UCS4 */
  553.     {
  554.         utf8len = 3;
  555.     }
  556. #ifdef DO_UCS4
  557. /* The following would be for UCS-4 */
  558.     else if (ucs2 < 0x200000) {
  559.         utf8len = 4;
  560.     } else if (ucs2 < 0x4000000) {
  561.         utf8len = 5;
  562.     } else if (ucs2 <=
  563. #ifdef CK_ANSIC
  564.            0x7FFFFFFFUL        /* (doesn't really need the "U") */
  565. #else
  566.            0x7FFFFFFFL
  567. #endif /* CK_ANSIC */
  568.            ) {            /* 31 bits = max for UCS4 */
  569.         utf8len = 6;
  570.     } else {
  571.         utf8len = 2;
  572.         ucs2 = 0xFFFD;                  /* Replacement for invalid char */
  573.     }
  574. #endif /* DO_UCS4 */
  575.     i = utf8len;                        /* index into utf8return */
  576.     utf8return[i--] = 0;                /* Null terminate the string */
  577.  
  578.     switch (utf8len) {                    /* code falls through cases! */
  579.       case 6: utf8return[i--] = (ucs2 | byteMark) & byteMask; ucs2 >>= 6;
  580.       case 5: utf8return[i--] = (ucs2 | byteMark) & byteMask; ucs2 >>= 6;
  581.       case 4: utf8return[i--] = (ucs2 | byteMark) & byteMask; ucs2 >>= 6;
  582.       case 3: utf8return[i--] = (ucs2 | byteMark) & byteMask; ucs2 >>= 6;
  583.       case 2: utf8return[i--] = (ucs2 | byteMark) & byteMask; ucs2 >>= 6;
  584.       case 1: utf8return[i--] =  ucs2 | firstByteMark[utf8len];
  585.     }
  586.     *utf8 = utf8return;
  587.     return(utf8len);
  588. }
  589.  
  590. /* #define TEST */
  591.  
  592. int
  593. main() {
  594.     USHORT x, k;
  595.     int i, n;
  596.     CHAR * buf = NULL;
  597.  
  598.     printf("UCS Terminal Private Use Area U+E100-E2FF\n");
  599.     printf("Char Hex   Ctrl  Name\n");
  600.  
  601.     for (x = 0; x < 512; x++) {
  602.  
  603.     k = (unsigned)((unsigned)0xE100 + x);
  604.     n = ucs2_to_utf8(k,&buf);
  605.     putchar('[');
  606.     for (i = 0; i < n; i++)
  607.       putchar(buf[i]);
  608.     putchar(']');
  609.     printf("  %s\n",name[x]);
  610.     }
  611. }
  612.