URL and HTML entities

The following table was created entirely with Perl, using CGI.pm and several other modules. The program listing is at the bottom.

Symbol ASCII Value URL encoded HTML code
  0 %00 �
  1 %01 
  2 %02 
  3 %03 
  4 %04 
  5 %05 
  6 %06 
  7 %07 
  8 %08 
  9 %09 	
  10 %0A 

  11 %0B 
  12 %0C 
  13 %0D 
  14 %0E 
  15 %0F 
  16 %10 
  17 %11 
  18 %12 
  19 %13 
  20 %14 
  21 %15 
  22 %16 
  23 %17 
  24 %18 
  25 %19 
  26 %1A 
  27 %1B 
  28 %1C 
  29 %1D 
  30 %1E 
  31 %1F 
  32 %20 or +  
! 33 %21 !
" 34 %22 "
# 35 %23 #
$ 36 %24 $
% 37 %25 %
& 38 %26 &
' 39 %27 '
( 40 %28 (
) 41 %29 )
* 42 * *
+ 43 %2B +
, 44 %2C ,
- 45 - -
. 46 . .
/ 47 %2F /
0 48 0 0
1 49 1 1
2 50 2 2
3 51 3 3
4 52 4 4
5 53 5 5
6 54 6 6
7 55 7 7
8 56 8 8
9 57 9 9
: 58 %3A :
; 59 %3B &#59;
< 60 %3C &lt;
= 61 %3D &#61;
> 62 %3E &gt;
? 63 %3F &#63;
@ 64 %40 &#64;
A 65 A A
B 66 B B
C 67 C C
D 68 D D
E 69 E E
F 70 F F
G 71 G G
H 72 H H
I 73 I I
J 74 J J
K 75 K K
L 76 L L
M 77 M M
N 78 N N
O 79 O O
P 80 P P
Q 81 Q Q
R 82 R R
S 83 S S
T 84 T T
U 85 U U
V 86 V V
W 87 W W
X 88 X X
Y 89 Y Y
Z 90 Z Z
[ 91 %5B &#91;
\ 92 %5C &#92;
] 93 %5D &#93;
^ 94 %5E &#94;
_ 95 _ _
` 96 %60 &#96;
a 97 a a
b 98 b b
c 99 c c
d 100 d d
e 101 e e
f 102 f f
g 103 g g
h 104 h h
i 105 i i
j 106 j j
k 107 k k
l 108 l l
m 109 m m
n 110 n n
o 111 o o
p 112 p p
q 113 q q
r 114 r r
s 115 s s
t 116 t t
u 117 u u
v 118 v v
w 119 w w
x 120 x x
y 121 y y
z 122 z z
{ 123 %7B &#123;
| 124 %7C &#124;
} 125 %7D &#125;
~ 126 %7E &#126;
 127 %7F &#127;
128 %80 &#128;
129 %81 &#129;
130 %82 &#130;
ƒ 131 %83 &#131;
132 %84 &#132;
133 %85 &#133;
134 %86 &#134;
135 %87 &#135;
ˆ 136 %88 &#136;
137 %89 &#137;
Š 138 %8A &#138;
139 %8B &#139;
Œ 140 %8C &#140;
141 %8D &#141;
Ž 142 %8E &#142;
143 %8F &#143;
144 %90 &#144;
145 %91 &#145;
146 %92 &#146;
147 %93 &#147;
148 %94 &#148;
149 %95 &#149;
150 %96 &#150;
151 %97 &#151;
˜ 152 %98 &#152;
153 %99 &#153;
š 154 %9A &#154;
155 %9B &#155;
œ 156 %9C &#156;
157 %9D &#157;
ž 158 %9E &#158;
Ÿ 159 %9F &#159;
  160 %A0 &nbsp;
¡ 161 %A1 &iexcl;
¢ 162 %A2 &cent;
£ 163 %A3 &pound;
¤ 164 %A4 &curren;
¥ 165 %A5 &yen;
¦ 166 %A6 &brvbar;
§ 167 %A7 &sect;
¨ 168 %A8 &uml;
© 169 %A9 &copy;
ª 170 %AA &ordf;
« 171 %AB &laquo;
¬ 172 %AC &not;
­ 173 %AD &shy;
® 174 %AE &reg;
¯ 175 %AF &macr;
° 176 %B0 &deg;
± 177 %B1 &plusmn;
² 178 %B2 &sup2;
³ 179 %B3 &sup3;
´ 180 %B4 &acute;
µ 181 %B5 &micro;
182 %B6 &para;
· 183 %B7 &middot;
¸ 184 %B8 &cedil;
¹ 185 %B9 &sup1;
º 186 %BA &ordm;
» 187 %BB &raquo;
¼ 188 %BC &frac14;
½ 189 %BD &frac12;
¾ 190 %BE &frac34;
¿ 191 %BF &iquest;
À 192 %C0 &Agrave;
Á 193 %C1 &Aacute;
 194 %C2 &Acirc;
à 195 %C3 &Atilde;
Ä 196 %C4 &Auml;
Å 197 %C5 &Aring;
Æ 198 %C6 &AElig;
Ç 199 %C7 &Ccedil;
È 200 %C8 &Egrave;
É 201 %C9 &Eacute;
Ê 202 %CA &Ecirc;
Ë 203 %CB &Euml;
Ì 204 %CC &Igrave;
Í 205 %CD &Iacute;
Î 206 %CE &Icirc;
Ï 207 %CF &Iuml;
Ð 208 %D0 &ETH;
Ñ 209 %D1 &Ntilde;
Ò 210 %D2 &Ograve;
Ó 211 %D3 &Oacute;
Ô 212 %D4 &Ocirc;
Õ 213 %D5 &Otilde;
Ö 214 %D6 &Ouml;
× 215 %D7 &times;
Ø 216 %D8 &Oslash;
Ù 217 %D9 &Ugrave;
Ú 218 %DA &Uacute;
Û 219 %DB &Ucirc;
Ü 220 %DC &Uuml;
Ý 221 %DD &Yacute;
Þ 222 %DE &THORN;
ß 223 %DF &szlig;
à 224 %E0 &agrave;
á 225 %E1 &aacute;
â 226 %E2 &acirc;
ã 227 %E3 &atilde;
ä 228 %E4 &auml;
å 229 %E5 &aring;
æ 230 %E6 &aelig;
ç 231 %E7 &ccedil;
è 232 %E8 &egrave;
é 233 %E9 &eacute;
ê 234 %EA &ecirc;
ë 235 %EB &euml;
ì 236 %EC &igrave;
í 237 %ED &iacute;
î 238 %EE &icirc;
ï 239 %EF &iuml;
ð 240 %F0 &eth;
ñ 241 %F1 &ntilde;
ò 242 %F2 &ograve;
ó 243 %F3 &oacute;
ô 244 %F4 &ocirc;
õ 245 %F5 &otilde;
ö 246 %F6 &ouml;
÷ 247 %F7 &divide;
ø 248 %F8 &oslash;
ù 249 %F9 &ugrave;
ú 250 %FA &uacute;
û 251 %FB &ucirc;
ü 252 %FC &uuml;
ý 253 %FD &yacute;
þ 254 %FE &thorn;
ÿ 255 %FF &yuml;

The above table was generated by the following program:

#!C:/perl/bin/perl.exe -w
# Please note that the taint switch (-T) is not used here as this is NOT
# a CGI program.  CGI.pm is merely used for its HTML generating functions.
use strict;

# This allows us to escape characters properly for query strings
use URI::Escape;

# This can be used to generate HTML character codes.
use HTML::Entities;

# Since this is a command line program, we don't want to be forced to
# enter name=value pairs.  Therefore, we use qw/:no_debug/
use CGI::Pretty qw/:no_debug/;
$CGI::Pretty::INDENT = "\t";

my $q = CGI->new();

# The logic is simple:  create the table data, read the source code, and use
# them to create the web page.  We could have done all of this without subroutines,
# but this allows us to revisit this program easily in the future and extend its
# functionality.  For many, this is a matter of personal preference.


# characters which must be encoded in query strings:
my $cgi_chars = '\x00-\x29\x2b\x2c\x2f\x3a-\x40\x5b-\x5e\x60\x7b-\xff';

# characters which often have their HTML character code equivalent used instead:
my $html_chars = '\x00-\x2f\x3a-\x40\x5b-\x5e\x60\x7b-\xff';

my $bit = 1;

sub row
{
	my $cell_method = shift;
	$q->Tr(
		{
			-align => 'right',
			-bgcolor => ('#FFFFFF','#CCCCCC')[ $bit ^= 1 ], # a flipping bit
		},
		$q->$cell_method( \@_ )
	)
}

my $outfile = "appendix2.html";
open OUT, '>', $outfile or die "Error opening $outfile for writing: $!\n";
print OUT $q->table(
	row( 'th', # header row
		'Symbol',
		'ASCII Value',
		'URL encoded',
		'HTML code'
	),
	map
	{
		my $char = chr $_; # The actual character
		my $symbol = encode_entities( $char, $html_chars ); # HTML code for web page
		my $escaped = uri_escape( $char, $cgi_chars ); # CGI representation
		my $html_code = encode_entities( $symbol ); # Re-encode HTML code so that it displays properly
		$escaped eq '%20' and $escaped .= ' or +'; # a space may be %20 or a +

		row( 'td',
			$_ < 33 ? '&nbsp;' : $symbol,
			$_,
			$escaped,
			$html_code
		)
	}
	0 .. 255
);
close OUT;