12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

54 BASE64 MIME DECODER ANNOYANCE-FILTER §56<br />

56. <strong>The</strong> initialiseDecodingTable method fills the binary encoding table with the characters the 6 bit<br />

values are mapped into. <strong>The</strong> curious and disparate sequences used to fill this table permit this code to<br />

work both on ASCII and EBCDIC systems.<br />

In EBCDIC systems character codes for letters are not consecutive; the initialisation must be split to<br />

accommodate the EBCDIC consecutive letters:<br />

A–I J–R S–Z a–i j–r s–z<br />

This code works on ASCII as well as EBCDIC systems.<br />

〈 Class implementations 11 〉 +≡<br />

void base64MIMEdecoder ::initialiseDecodingTable (void)<br />

{<br />

int i;<br />

for (i = 0; i < 255; i++) {<br />

dtable [i] = # 80;<br />

}<br />

for (i = ’A’; i ≤ ’I’; i++) {<br />

dtable [i] = 0 + (i − ’A’);<br />

}<br />

for (i = ’J’; i ≤ ’R’; i++) {<br />

dtable [i] = 9 + (i − ’J’);<br />

}<br />

for (i = ’S’; i ≤ ’Z’; i++) {<br />

dtable [i] = 18 + (i − ’S’);<br />

}<br />

for (i = ’a’; i ≤ ’i’; i++) {<br />

dtable [i] = 26 + (i − ’a’);<br />

}<br />

for (i = ’j’; i ≤ ’r’; i++) {<br />

dtable [i] = 35 + (i − ’j’);<br />

}<br />

for (i = ’s’; i ≤ ’z’; i++) {<br />

dtable [i] = 44 + (i − ’s’);<br />

}<br />

for (i = ’0’; i ≤ ’9’; i++) {<br />

dtable [i] = 52 + (i − ’0’);<br />

}<br />

#define CI(x)static cast〈int〉 (x)<br />

dtable [CI(’+’)] = 62;<br />

dtable [CI(’/’)] = 63;<br />

dtable [CI(’=’)] = 0;<br />

#undef CI<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!