Subj : Encoder in C... To : Frank Reid From : Angus Mcleod Date : Thu Dec 02 2004 09:00 am Here's a quick'n'dirty attempt at an encoder: #include #include int main( int argc, char **argv ) { char *p, *q, *allowed = "-_.!~*'()"; argv++; // skip argv[0] while (*argv) { p = *argv; while (*p) { if (((*p >= '0') && (*p <= '9')) || // digit ((*p >= 'A') && (*p <= 'Z')) || // upper case ((*p >= 'a') && (*p <= 'z')) || // lower case (strchr( allowed, *p ) != NULL)) { // allowed putchar( *p++ ); } else printf( "%%%02X", *p++ ); // char must be encoded } argv++; } putchar( '\n' ); return 0; } I'd have preferred to build up the result in a buffer and then done a single puts() at the end, but then the question of how big a buffer is adequate raises it's ugly head..... Is there a way to fill the char *allowed array with the UC and LC alphabet and the list of digits with*OUT* typing them out in full? It would simplify the if() condition considerably. --- þ Synchronet þ Linus is a regular at The ANJO BBS. No, Linus Brathwaite! .