ASCII 字符集:美国信息交换标准编码

ASCII and Latin-1 Character Table
Char Dec Hex Octal HTML Notes
0 0x00 0000 ␀ ^@ NUL (Null)
1 0x01 0001 ␁ ^A SOH (Start OHeader)
2 0x02 0002 ␂ ^B STX (Start of Text)
3 0x03 0003 ␃ ^C ETX (End of Text)
4 0x04 0004 ␄ ^D EOT (End OTransmission)
5 0x05 0005 ␅ ^E ENQ (Enquiry)
6 0x06 0006 ␆ ^F ACK (Acknowledge)
7 0x07 0007 ␇ ^G BEL (Bell)
8 0x08 0010 ␈ ^H BS (Backspace) [\b]
9 0x09 0011 ␉ ^I HT (Horizontal Tab) [\t]
10 0x0a 0012 ␊ ^J LF (Line Feed) [\n]
11 0x0b 0013 ␋ ^K VT (Vertical Tab)
12 0x0c 0014 ␌ ^L FF (Form Feed) [\f]
13 0x0d 0015 ␍ ^M CR (Carriage Return) [\r]
14 0x0e 0016 ␎ ^N SO (Shift Out)
15 0x0f 0017 ␏ ^O SI (Shift In)
16 0x10 0020 ␐ ^P DLE (Data Link Escape)
17 0x11 0021 ␑ ^Q DC1 (Device Control 1), XON resume transmission
18 0x12 0022 ␒ ^R DC2 (Device Control 2)
19 0x13 0023 ␓ ^S DC3 (Device Control 3), XOFF pause transmission
20 0x14 0024 ␔ ^T DC4 (Device Control 4)
21 0x15 0025 ␕ ^U NAK (Negative Acknowledbge)
22 0x16 0026 ␖ ^V SYN (Synchronise)
23 0x17 0027 ␗ ^W ETB (End Text Block)
24 0x18 0030 ␘ ^X CAN (Cancel)
25 0x19 0031 ␙ ^Y EM (End of Medium)
26 0x1a 0032 ␚ ^Z SUB (Substitute)
27 0x1b 0033 ␛ ^[ ESC (Escape)
28 0x1c 0034 ␜ ^\ FS (File Separator), originally used to separate files in a stream.
29 0x1d 0035 ␝ ^] GS (Group Separator), originally used to separate groups of similar records (tables) in a stream
30 0x1e 0036 ␞ ^^ RS (Record Separator), originally used to separate records.
31 0x1f 0037 ␟ ^_ US (Unit Separator), originally used to separate fields (or units as they were once called).
  32 0x20 0040   space
! 33 0x21 0041 ! bang, exclamation
" 34 0x22 0042 " quote
# 35 0x23 0043 # sharp, number sign
$ 36 0x24 0044 $ dollar sign
% 37 0x25 0045 % percent
& 38 0x26 0046 & ampersand
' 39 0x27 0047 ' apostrophe
( 40 0x28 0050 ( left parenthesis
) 41 0x29 0051 ) right parenthesis
* 42 0x2a 0052 * star, asterisk
+ 43 0x2b 0053 + plus
, 44 0x2c 0054 , comma
- 45 0x2d 0055 - minus
. 46 0x2e 0056 . period
/ 47 0x2f 0057 / slash, ,not backslash!
0 48 0x30 0060 0 digit 0
1 49 0x31 0061 1 digit 1
2 50 0x32 0062 2 digit 2
3 51 0x33 0063 3 digit 3
4 52 0x34 0064 4 digit 4
5 53 0x35 0065 5 digit 5
6 54 0x36 0066 6 digit 6
7 55 0x37 0067 7 digit 7
8 56 0x38 0070 8 digit 8
9 57 0x39 0071 9 digit 9
: 58 0x3a 0072 : colon
; 59 0x3b 0073 ; semicolon
< 60 0x3c 0074 &lt; less than
= 61 0x3d 0075 = equals
> 62 0x3e 0076 &gt; greater than
? 63 0x3f 0077 ? question mark
@ 64 0x40 0100 @ at sign
A 65 0x41 0101 A upper case A
B 66 0x42 0102 B upper case B
C 67 0x43 0103 C upper case C
D 68 0x44 0104 D upper case D
E 69 0x45 0105 E upper case E
F 70 0x46 0106 F upper case F
G 71 0x47 0107 G upper case G
H 72 0x48 0110 H upper case H
I 73 0x49 0111 I upper case I
J 74 0x4a 0112 J upper case J
K 75 0x4b 0113 K upper case K
L 76 0x4c 0114 L upper case L
M 77 0x4d 0115 M upper case M
N 78 0x4e 0116 N upper case N
O 79 0x4f 0117 O upper case O
P 80 0x50 0120 P upper case P
Q 81 0x51 0121 Q upper case Q
R 82 0x52 0122 R upper case R
S 83 0x53 0123 S upper case S
T 84 0x54 0124 T upper case T
U 85 0x55 0125 U upper case U
V 86 0x56 0126 V upper case V
W 87 0x57 0127 W upper case W
X 88 0x58 0130 X upper case X
Y 89 0x59 0131 Y upper case Y
Z 90 0x5a 0132 Z upper case Z
[ 91 0x5b 0133 [ left square bracket
\ 92 0x5c 0134 \ backslash, not slash!
] 93 0x5d 0135 ] right square bracket
^ 94 0x5e 0136 ^ hat, circumflex
_ 95 0x5f 0137 _ underscore
` 96 0x60 0140 ` grave, rhymes with have
a 97 0x61 0141 a lower case a
b 98 0x62 0142 b lower case b
c 99 0x63 0143 c lower case c
d 100 0x64 0144 d lower case d
e 101 0x65 0145 e lower case e
f 102 0x66 0146 f lower case f
g 103 0x67 0147 g lower case g
h 104 0x68 0150 h lower case h
i 105 0x69 0151 i lower case i
j 106 0x6a 0152 j lower case j
k 107 0x6b 0153 k lower case k
l 108 0x6c 0154 l lower case l
m 109 0x6d 0155 m lower case m
n 110 0x6e 0156 n lower case n
o 111 0x6f 0157 o lower case o
p 112 0x70 0160 p lower case p
q 113 0x71 0161 q lower case q
r 114 0x72 0162 r lower case r
s 115 0x73 0163 s lower case s
t 116 0x74 0164 t lower case t
u 117 0x75 0165 u lower case u
v 118 0x76 0166 v lower case v
w 119 0x77 0167 w lower case w
x 120 0x78 0170 x lower case x
y 121 0x79 0171 y lower case y
z 122 0x7a 0172 z lower case z
{ 123 0x7b 0173 { left curly brace
| 124 0x7c 0174 | vertical bar
} 125 0x7d 0175 } right curly brace
~ 126 0x7e 0176 ~ tilde
  127 0x7f 0177 &#x7f; DEL (Delete)
  128 0x80 0200 &#x80;  
  129 0x81 0201 &#x81;  
  130 0x82 0202 &#x82;  
  131 0x83 0203 &#x83;  
  132 0x84 0204 &#x84;  
  133 0x85 0205 &#x85;  
  134 0x86 0206 &#x86;  
  135 0x87 0207 &#x87;  
  136 0x88 0210 &#x88;  
  137 0x89 0211 &#x89;  
  138 0x8a 0212 &#x8a;  
  139 0x8b 0213 &#x8b;  
  140 0x8c 0214 &#x8c;  
  141 0x8d 0215 &#x8d;  
  142 0x8e 0216 &#x8e;  
  143 0x8f 0217 &#x8f;  
  144 0x90 0220 &#x90;  
  145 0x91 0221 &#x91;  
  146 0x92 0222 &#x92;  
  147 0x93 0223 &#x93;  
  148 0x94 0224 &#x94;  
  149 0x95 0225 &#x95;  
  150 0x96 0226 &#x96;  
  151 0x97 0227 &#x97;  
  152 0x98 0230 &#x98;  
  153 0x99 0231 &#x99;  
  154 0x9a 0232 &#x9a;  
  155 0x9b 0233 &#x9b;  
  156 0x9c 0234 &#x9c;  
  157 0x9d 0235 &#x9d;  
  158 0x9e 0236 &#x9e;  
  159 0x9f 0237 &#x9f;  
  160 0xa0 0240 &nbsp;  
¡ 161 0xa1 0241 &iexcl; PostScript (¡) exclamdown
¢ 162 0xa2 0242 &cent; PostScript (¢) cent
£ 163 0xa3 0243 &pound; PostScript (£) sterling
¤ 164 0xa4 0244 &curren; PostScript (/) fraction
¥ 165 0xa5 0245 &yen; PostScript (¥) yen
¦ 166 0xa6 0246 &brvbar; PostScript (ƒ) florin
§ 167 0xa7 0247 &sect; PostScript (§) section
¨ 168 0xa8 0250 &uml; PostScript (¤) currency
© 169 0xa9 0251 &copy; PostScript (') quotesingle
ª 170 0xaa 0252 &ordf; PostScript (“) quotedblleft
« 171 0xab 0253 &laquo; PostScript («) guillemotleft
¬ 172 0xac 0254 &not; PostScript (<) guilsinglleft
  173 0xad 0255 &shy; PostScript (>) guilsinglright
® 174 0xae 0256 &reg; PostScript fi ligature
¯ 175 0xaf 0257 &macr; PostScript fl ligature;
° 176 0xb0 0260 &deg;  
± 177 0xb1 0261 &plusmn; PostScript (–) endash
² 178 0xb2 0262 &sup2; PostScript (†) dagger
³ 179 0xb3 0263 &sup3; PostScript (·) periodcentered
´ 180 0xb4 0264 &acute;  
µ 181 0xb5 0265 &micro;  
182 0xb6 0266 &para; PostScript (¶) paragraph
· 183 0xb7 0267 &middot; PostScript (•) bullet
¸ 184 0xb8 0270 &cedil; PostScript (,) quotesinglbase
¹ 185 0xb9 0271 &sup1; PostScript („) quotedblbase
º 186 0xba 0272 &ordm; PostScript (”) quotedblright
» 187 0xbb 0273 &raquo; PostScript (») guillemotright
¼ 188 0xbc 0274 &frac14; PostScript (…) ellipsis
½ 189 0xbd 0275 &frac12; PostScript (‰) perthousand
¾ 190 0xbe 0276 &frac34;  
¿ 191 0xbf 0277 &iquest; PostScript (¿) questiondown
À 192 0xc0 0300 &Agrave;  
Á 193 0xc1 0301 &Aacute; PostScript (`) grave
 194 0xc2 0302 &Acirc; PostScript (´) acute
à 195 0xc3 0303 &Atilde; PostScript (^) circumflex
Ä 196 0xc4 0304 &Auml; PostScript (~) tilde
Å 197 0xc5 0305 &Aring; PostScript (¯) macron, overbar accent
Æ 198 0xc6 0306 &AElig; PostScript (u) breve, flattened u-shaped accent
Ç 199 0xc7 0307 &Ccedil; PostScript (·) dotaccent
È 200 0xc8 0310 &Egrave; PostScript (¨) dieresis
É 201 0xc9 0311 &Eacute;  
Ê 202 0xca 0312 &Ecirc; PostScript (°) ring
Ë 203 0xcb 0313 &Euml; PostScript (¸) cedilla
Ì 204 0xcc 0314 &Igrave;  
Í 205 0xcd 0315 &Iacute; PostScript (”) hungarumlaut
Î 206 0xce 0316 &Icirc; PostScript (,) ogonek, reverse comma
Ï 207 0xcf 0317 &Iuml; PostScript (v) caron, flattened v-shaped accent
Ð 208 0xd0 0320 &ETH; PostScript (—) emdash
Ñ 209 0xd1 0321 &Ntilde;  
Ò 210 0xd2 0322 &Ograve;  
Ó 211 0xd3 0323 &Oacute;  
Ô 212 0xd4 0324 &Ocirc;  
Õ 213 0xd5 0325 &Otilde;  
Ö 214 0xd6 0326 &Ouml;  
× 215 0xd7 0327 &times;  
Ø 216 0xd8 0330 &Oslash;  
Ù 217 0xd9 0331 &Ugrave;  
Ú 218 0xda 0332 &Uacute;  
Û 219 0xdb 0333 &Ucirc;  
Ü 220 0xdc 0334 &Uuml;  
Ý 221 0xdd 0335 &Yacute;  
Þ 222 0xde 0336 &THORN;  
ß 223 0xdf 0337 &szlig;  
à 224 0xe0 0340 &agrave;  
á 225 0xe1 0341 &aacute; PostScript (Æ) AE
â 226 0xe2 0342 &acirc;  
ã 227 0xe3 0343 &atilde; PostScript (ª) ordfeminine
ä 228 0xe4 0344 &auml;  
å 229 0xe5 0345 &aring;  
æ 230 0xe6 0346 &aelig;  
ç 231 0xe7 0347 &ccedil;  
è 232 0xe8 0350 &egrave; PostScript (L/) Lslash, L with / overstrike
é 233 0xe9 0351 &eacute; PostScript (Ø) Oslash
ê 234 0xea 0352 &ecirc; PostScript (Œ) OE
ë 235 0xeb 0353 &euml; PostScript (º) ordmasculine
ì 236 0xec 0354 &igrave;  
í 237 0xed 0355 &iacute;  
î 238 0xee 0356 &icirc;  
ï 239 0xef 0357 &iuml;  
ð 240 0xf0 0360 &eth;  
ñ 241 0xf1 0361 &ntilde; PostScript (æ) ae
ò 242 0xf2 0362 &ograve;  
ó 243 0xf3 0363 &oacute;  
ô 244 0xf4 0364 &ocirc;  
õ 245 0xf5 0365 &otilde; PostScript (1) dotlessi, i without dot
ö 246 0xf6 0366 &ouml;  
÷ 247 0xf7 0367 &divide;  
ø 248 0xf8 0370 &oslash; PostScript (l/) l with / overstrike
ù 249 0xf9 0371 &ugrave; PostScript (ø) oslash
ú 250 0xfa 0372 &uacute; PostScript (œ) oe
û 251 0xfb 0373 &ucirc; PostScript (ß) germandbls
ü 252 0xfc 0374 &uuml;  
ý 253 0xfd 0375 &yacute;  
þ 254 0xfe 0376 &thorn;  
ÿ 255 0xff 0377 &yuml;  

上面信息由以下Java代码生成

/*
 * [Asciitab.java]
 *
 * Summary: prepares ASCII table in HTML.
 *
 * Copyright: (c) 2001-2017 Roedy Green, Canadian Mind Products, http://mindprod.com
 *
 * Licence: This software may be copied and used freely for any purpose but military.
 *          http://mindprod.com/contact/nonmil.html
 *
 * Requires: JDK 1.8+
 *
 * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/
 *
 * Version History:
 *  1.1 2009-03-22 add style markup, character entities
 *  1.2 2011-11-23 integrate into Palette
 */
package com.mindprod.palette;
import com.mindprod.common18.BigDate;
import com.mindprod.entities.EntifyStrings;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import static java.lang.System.*;
/**
 * prepares ASCII table in HTML.
 * <p/>
 * Does not run standalone. run when Palette is run.
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.2 2011-11-23 integrate into Palette
 * @since 2001
 */
final class Asciitab
    {
    private static final String DO_NOT_EDIT = "<!-- The following table was generated on " + BigDate.localToday().toString() + " by AsciiTab. D o   n o t   e d i t . -->\n";
    /**
     * how you display this character in HTML
     *
     * @param c the character you want to render
     *
     * @return html for rendering the character
     */
    private static String asHTML( char c )
        {
        if ( c < 32 )
            {
            /* control char */
            return "&#x" + toLZ( c + 0x2400, 4, 16 ) + ";";
            }
        else if ( c > 126 )
            {
            /* high ascii */
            // decimal form: "&#" + Integer.toString( c ) + ";";
            return EntifyStrings.entifyHTML( String.valueOf( c ) );
            }
        else
            {
            switch ( c )
                {
                case 32:
                    return " ";
                case 38:
                    return "&";
                case 34:
                    return """;
                case 60:
                    return "<";
                case 62:
                    return ">";
                /* ordinary char */
                default:
                    return String.valueOf( c );
                }
            }
        }
    /**
     * how you display this character in HTML, quoted so you can see the code
     *
     * @param c the character you want to render
     *
     * @return html for rendering the character
     */
    private static String asQuotedHTML( char c )
        {
        String result = asHTML( c );
        if ( result.charAt( 0 ) == '&' )
            {
            return "&" + result.substring( 1 );
            }
        else
            {
            return result;
            }
        }
    /**
     * Get description of a character
     *
     * @param c character to describe
     *
     * @return string destribing character, or   if none available.
     */
    @SuppressWarnings( { "OctalInteger" } )
    private static String descs( char c )
        {
        if ( 'A' <= c && c <= 'Z' )
            {
            return "upper case " + String.valueOf( c );
            }
        else if ( 'a' <= c && c <= 'z' )
            {
            return "lower case " + String.valueOf( c );
            }
        else if ( '0' <= c && c <= '9' )
            {
            return "digit " + String.valueOf( c );
            }
        else
            {
            switch ( c )
                {
                case 0:
                    return "^@ <!-- macro Acronym NUL_ctrl -->";
                case 1:
                    return "^A <!-- macro Acronym SOH_ctrl -->";
                case 2:
                    return "^B <!-- macro Acronym STX_ctrl -->";
                case 3:
                    return "^C <!-- macro Acronym ETX_ctrl -->";
                case 4:
                    return "^D <!-- macro Acronym EOT_ctrl -->";
                case 5:
                    return "^E <!-- macro Acronym ENQ_ctrl -->";
                case 6:
                    return "^F <!-- macro Acronym ACK_ctrl -->";
                case 7:
                    return "^G <!-- macro Acronym BEL_ctrl -->";
                case 8:
                    return "^H <!-- macro Acronym BS_ctrl --> [\\b]";
                case 9:
                    return "^I <!-- macro Acronym HT_ctrl --> [\\t]";
                case 10:
                    return "^J <!-- macro Acronym LF_ctrl --> [\\n]";
                case 11:
                    return "^K <!-- macro Acronym VT_ctrl -->";
                case 12:
                    return "^L <!-- macro Acronym FF_ctrl --> [\\f]";
                case 13:
                    return "^M <!-- macro Acronym CR_ctrl --> [\\r]";
                case 14:
                    return "^N <!-- macro Acronym SO_ctrl -->";
                case 15:
                    return "^O <!-- macro Acronym SI_ctrl -->";
                case 16:
                    return "^P <!-- macro Acronym DLE_ctrl -->";
                case 17:
                    return "^Q <!-- macro Acronym DC1 -->, XON resume transmission";
                case 18:
                    return "^R <!-- macro Acronym DC2 -->";
                case 19:
                    return "^S <!-- macro Acronym DC3 -->, XOFF pause transmission";
                case 20:
                    return "^T <!-- macro Acronym DC4 -->";
                case 21:
                    return "^U <!-- macro Acronym NAK_ctrl -->";
                case 22:
                    return "^V <!-- macro Acronym SYN_ctrl -->";
                case 23:
                    return "^W <!-- macro Acronym ETB_ctrl -->";
                case 24:
                    return "^X <!-- macro Acronym CAN_ctrl -->";
                case 25:
                    return "^Y <!-- macro Acronym EM_ctrl -->";
                case 26:
                    return "^Z <!-- macro Acronym SUB_ctrl -->";
                case 27:
                    return "^[ <!-- macro Acronym ESC_ctrl -->";
                case 28:
                    return "^\\ <!-- macro Acronym FS_ctrl -->, originally used to separate files in a stream.";
                case 29:
                    return "^] <!-- macro Acronym GS_ctrl -->, originally used to separate groups of similar records " +
                           "(tables) in a stream";
                case 30:
                    return "^^ <!-- macro Acronym RS_ctrl -->, originally used to separate records.";
                case 31:
                    return "^_ <!-- macro Acronym US_ctrl -->, originally used to separate fields (or units as they were" +
                           " once called).";
                case 32:
                    return "space";
                case 33:
                    return "bang, exclamation";
                case 34:
                    return "quote";
                case 35:
                    return "sharp, number sign";
                case 36:
                    return "dollar sign";
                case 37:
                    return "percent";
                case 38:
                    return "ampersand";
                case 39:
                    return "apostrophe";
                case 40:
                    return "left parenthesis";
                case 41:
                    return "right parenthesis";
                case 42:
                    return "star, asterisk";
                case 43:
                    return "plus";
                case 44:
                    return "comma";
                case 45:
                    return "minus";
                case 46:
                    return "period";
                case 47:
                    return "slash, ,<strong>not backslash!</strong>";
                case 58:
                    return "colon";
                case 59:
                    return "semicolon";
                case 60:
                    return "less than";
                case 61:
                    return "equals";
                case 62:
                    return "greater than";
                case 63:
                    return "question mark";
                case 64:
                    return "at sign";
                case 91:
                    return "left square bracket";
                case 92:
                    return "backslash, <strong>not slash!</strong>";
                case 93:
                    return "right square bracket";
                case 94:
                    return "hat, circumflex";
                case 95:
                    return "underscore";
                case 96:
                    return "grave, rhymes with have";
                case 123:
                    return "left curly brace";
                case 124:
                    return "vertical bar";
                case 125:
                    return "right curly brace";
                case 126:
                    return "tilde";
                case 127:
                    return "<!-- macro Acronym DEL_ctrl -->";
                // the following are OCTAL because that's  how PostScript specifies them
                // &xxx; codes are for Latin-1
                case 0241:
                    return "PostScript (¡) exclamdown";
                case 0242:
                    return "PostScript (¢) cent";
                case 0243:
                    return "PostScript (£) sterling";
                case 0244:
                    return "PostScript (/) fraction";
                case 0245:
                    return "PostScript (¥) yen";
                case 0246:
                    return "PostScript (ƒ) florin";
                case 0247:
                    return "PostScript (§) section";
                case 0250:
                    return "PostScript (¤) currency";
                case 0251:
                    return "PostScript (') quotesingle";
                case 0252:
                    return "PostScript (“) quotedblleft";
                case 0253:
                    return "PostScript («) guillemotleft";
                case 0254:
                    return "PostScript (<) guilsinglleft";
                case 0255:
                    return "PostScript (>) guilsinglright";
                case 0256:
                    return "PostScript fi ligature";
                case 0257:
                    return "PostScript fl ligature;";
                case 0261:
                    return "PostScript (–) endash";
                case 0262:
                    return "PostScript (†) dagger";
                case 0263:
                    return "PostScript (·) periodcentered";
                case 0266:
                    return "PostScript (¶) paragraph";
                case 0267:
                    return "PostScript (•) bullet";
                case 0270:
                    return "PostScript (,) quotesinglbase";
                case 0271:
                    return "PostScript („) quotedblbase";
                case 0272:
                    return "PostScript (”) quotedblright";
                case 0273:
                    return "PostScript (») guillemotright";
                case 0274:
                    return "PostScript (…) ellipsis";
                case 0275:
                    return "PostScript (‰) perthousand";
                case 0277:
                    return "PostScript (¿) questiondown";
                case 0301:
                    return "PostScript (`) grave";
                case 0302:
                    return "PostScript (´) acute";
                case 0303:
                    return "PostScript (^) circumflex";
                case 0304:
                    return "PostScript (~) tilde";
                case 0305:
                    return "PostScript (¯) macron, overbar accent";
                case 0306:
                    return "PostScript (<sup>u</sup>) breve, flattened u-shaped accent";
                case 0307:
                    return "PostScript (·) dotaccent";
                case 0310:
                    return "PostScript (¨) dieresis";
                case 0312:
                    return "PostScript (°) ring";
                case 0313:
                    return "PostScript (¸) cedilla";
                case 0315:
                    return "PostScript (”) hungarumlaut";
                case 0316:
                    return "PostScript (,) ogonek, reverse comma";
                case 0317:
                    return "PostScript (<sup>v</sup>) caron, flattened v-shaped accent";
                case 0320:
                    return "PostScript (—) emdash";
                case 0341:
                    return "PostScript (Æ) AE";
                case 0343:
                    return "PostScript (ª) ordfeminine";
                case 0350:
                    return "PostScript (L/) Lslash, L with / overstrike";
                case 0351:
                    return "PostScript (Ø) Oslash";
                case 0352:
                    return "PostScript (Œ) OE";
                case 0353:
                    return "PostScript (º) ordmasculine";
                case 0361:
                    return "PostScript (æ) ae";
                case 0365:
                    return "PostScript (1) dotlessi, i without dot";
                case 0370:
                    return "PostScript (l/) l with / overstrike";
                case 0371:
                    return "PostScript (ø) oslash";
                case 0372:
                    return "PostScript (œ) oe";
                case 0373:
                    return "PostScript (ß) germandbls";
                default:
                    return " ";
                }
            }
        }
    /**
     * Generate ascii table
     *
     * @param dir      target dir where generated file goes.
     * @param filename filename where to put the generated table
     */
    @SuppressWarnings( { "SameParameterValue" } )
    static void generateAsciitab( final File dir, final String filename )
        {
        try
            {
            FileWriter p = new FileWriter( new File( dir, filename ) );
            p.write( "\n" );
            p.write( DO_NOT_EDIT +
                     "<table class=\"standard\"><caption class=\"hidden\">ASCII and Latin-1 Character Table</caption>\n" );
            p.write( "<colgroup><col style=\"text-align:center\" class=\"behold\"><col span=\"3\"" +
                     " style=\"text-align:right\" ><col span=\"2\"" +
                     " style=\"text-align:left\"></colgroup>\n" );
            p.write( "<thead><tr><th colspan=\"6\">ASCII and Latin-1 Character Table</th></tr>" );
            p.write( "<tr><th>Char</th><th>Dec</th><th>Hex</th><th>Octal</th><th>HTML</th><th>Notes</th></tr></thead" +
                     ">\n<tbody>\n" );
            int everyTenthLine = 0;
            for ( char c = 0; c <= 0xff; c++ )
                {
                p.write( "<tr>" );
                /* displayable char */
                p.write( "<td class=\"behold\">" );
                if ( !isControlChar( c ) )
                    {
                    p.write( asHTML( c ) );   // avoid generated raw unprintable char
                    }
                p.write( "</td>" );
                /* decimal */
                p.write( "<td class=\"decimal\">" );
                p.write( Integer.toString( c ) );
                p.write( "</td>" );
                /* hex */
                p.write( "<td class=\"hexentity\">" );
                p.write( "0x" + toLZ( c, 2, 16 ) );
                p.write( "</td>" );
                /* octal */
                p.write( "<td class=\"octal\">" );
                p.write( toLZ( c, 4, 8 ) );
                p.write( "</td>" );
                /* HTML entity */
                p.write( "<td class=\"entity\">" );
                p.write( asQuotedHTML( c ) );
                p.write( "</td>" );
                /* notes */
                p.write( "<td>" );
                p.write( descs( c ) );
                p.write( "</td>" );
                p.write( "</tr>\n" );
                } // end for
            p.write( "</tbody></table>" );
            p.write( "\n" );
            p.close();
            }
        catch ( IOException e )
            {
            err.println( e.getMessage() );
            }
        }
    /**
     * is this char an unprintable control char?
     *
     * @param theCharNumber
     *
     * @return true if is a control char
     */
    private static boolean isControlChar( int theCharNumber )
        {
        // leave low control chars. They have special glyphms
        return 127 <= theCharNumber && theCharNumber <= 159;
        }
    /**
     * Convert an integer to a String, with left zeroes.
     *
     * @param i    the integer to be converted
     * @param len  len the length of the resulting string
     * @param base base 10=decimal 16=hex 8=octal
     *
     * @return String representation of the int e.g. 007
     */
    private static String toLZ( int i, int len, int base )
        {
        // Since String is final, we could not add this method there.
        String s = Integer.toString( i, base );
        if ( s.length() > len )
            {
            return s.substring( 0, len );
            }
        else if ( s.length() < len )
            // pad on left with zeros
            {
            return "000000000000000000000000000".substring( 0,
                    len - s.length() )
                   + s;
            }
        else
            {
            return s;
            }
        } // end toLZ
    }
来源:http://mindprod.com/jgloss/ascii.html#WARTS

参考:http://redgrittybrick.org/ascii.html
发布了392 篇原创文章 · 获赞 487 · 访问量 239万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览