<<< Date Index >>>     <<< Thread Index >>>

Re: Demoroniser (was: Display Filters)



On 2006-07-03, Gary Johnson <garyjohn@xxxxxxxxxxxxxxx> wrote:

> I have attached the C source for the filter I really use for this 
> purpose.

Oops.  Here it is.

Gary

-- 
Gary Johnson                               | Agilent Technologies
garyjohn@xxxxxxxxxxxxxxx                   | Wireless Division
http://www.spocom.com/users/gjohnson/mutt/ | Spokane, Washington, USA
/* iso8859toascii - filter to translate the ISO-8859 character set with
 *                  Microsoft Latin-1 extensions to ASCII
 *
 * Written by:  Gary Johnson <garyjohn@xxxxxxxxxxxxxxx>
 *              June 1999
 */

/* For e-mail containing Microsoft "iso-8859-1" quoted-printable text. */
/* Reference: <http://www.bbsinc.com/iso8859.html> */
/* <http://www.uni-passau.de/~ramsch/iso8859-1.html> [good] */
/* <http://czyborra.com/charsets/iso8859.html> */

/* An InfoSeek search for "ISO 8859" turns up a lot of good stuff. */

/* Thu Jan  3 11:47:24 PST 2002
 * Incorporated some character mappings from the demoronizer,
 * http://www.fourmilab.ch/webtools/demoroniser/
 */

#include <stdlib.h>
#include <stdio.h>

#define TABLE_START     128
#define TABLE_SIZE      (sizeof(table)/sizeof(char *))
#define TABLE_END       (TABLE_START + TABLE_SIZE)

const char * const table[] = {
    "",         /* 0x80, 128, \200: */
    "",
    "",
    "",
    "",
    "...",      /* 0x85, 133, \205:  ellipsis (M$) */
    "",
    "",
    "",         /* 0x88, 136, \210: */
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    "",         /* 0x90, 144, \220: */
    "`",        /* 0x91, 145, \221: left single quote (M$) */
    "'",        /* 0x92, 146, \222: right single quote, apostrophe (M$) */
    "\"",       /* 0x93, 147, \223: left double quote (M$) */
    "\"",       /* 0x94, 148, \224: right double quote (M$) */
    "*",        /* 0x95, 149, \225: round filled bullet (M$) */
    "-",        /* 0x96, 150, \226: en dash (M$) */
    "--",       /* 0x97, 151, \227: em dash (M$) */
    "",         /* 0x98, 152, \230: */
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    " ",        /* 0xA0, 160, \240: non-breaking space */
    "",
    "",
    "",
    "",
    "",
    "",
    "o",        /* 0xA7, 167, \247: [some sort of bullet] */
    "",         /* 0xA8, 168, \250: */
    "",
    "",
    "<<",       /* 0xAB */
    "",
    "-",        /* 0xAD, 173, \255: soft hyphen */
    "",
    "",
    "",         /* 0xB0, 176, \260: */
    "+-",       /* 0xB1, 177, \261: plus-or-minus */
    "",
    "",
    "'",        /* 0xB4, 180, \264: acute accent */
    "u",        /* 0xB5, 181, \265: micro sign */
    "",
    "*",        /* 0xB7, 183, \267: middle dot, centered dot */
                                    /* Used period (.) for a while, */
                                    /* but it looked bad. */
    "",         /* 0xB8, 184, \270: */
    "",
    "",
    ">>",       /* 0xBB */
    "",
    "",
    "",
    "",
    "",         /* 0xC0, 192, \300: */
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    "",         /* 0xC8, 200, \310: */
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    "",         /* 0xD0, 208, \320: */
    "",
    "",
    "",
    "",
    "",
    "",
    "",
    ">",        /* 0xD8, 216, \330: [fancy right arrow head] */

};

main(void) {
    int c;

    while ((c = getchar()) != EOF) {
        if (   (c >= TABLE_START)
            && (c <= TABLE_END)
            && (*table[c - TABLE_START])) {
            fputs(table[c - TABLE_START], stdout);
        }
        else {
            putchar(c);
        }
    }

    exit(0);
    /* NOTREACHED */
}