Carl Cerecke wrote:
Martin, to his credit, solved it the hard way.
Here's the hard way in python (slightly modified version of the
unquote function from
the library.)
Bah! Luxury.
Here is how we used to do it....
#include <stdio.h>
#define READ_SIZE 1024
void unesc( FILE *fp )
{
char inbuf[READ_SIZE];
int nr, i;
while( !feof( fp ) )
{
*inbuf = 0;
fgets( inbuf, READ_SIZE-1, fp );
for( i = 0; inbuf[i]; i++ )
{
if( inbuf[i] == '%' && inbuf[i+1] && inbuf[i+2] )
{
char a = toupper(inbuf[i+1]);
char b = toupper(inbuf[i+2]);
putchar( (a-(a >= 'A'?'7':'0'))*16+(b-(b >= 'A'?'7':'0')) );
i += 2;
}
else
putchar( inbuf[i] );
}
}
}
int main( int argc, char **argv )
{
int i;
if( argc > 1 )
for( i = 1; i < argc; i++ )
{
FILE *infp;
if( infp = fopen( argv[i], "r" ) )
{
printf( "===%s====\n", argv[i] );
unesc( infp );
fclose( infp );
}
else
return 1;
}
else
unesc( stdin );
return 0;
}
:)
Cheers, Rex