All pastes #1167042 Raw Edit

Anonymous

public c v1 · immutable
#1167042 ·published 2008-08-12 00:10 UTC
rendered paste body
char* Retard2Ascii( char *input ){	int i, n, x, y, l;	int length = 256;	char *html;	char *copy;	char code[3];	bool onchar = false;		n = y = i = 0;	html = malloc( length );	strcpy( html, input );	l = strlen( html );	copy = malloc( l - ( charcnt(html, '%') * 2) );	for ( i = 0; i < l; i++ )		if ( html[i] == '+' )			html[i] = 32;	for ( i = 0; i < l; i++ ) {		if ( html[i] == '%' ) {			onchar = true;			continue;		}		if ( onchar )			code[n++]	= html[i];				if ( n == 2 ) {			code[n]		= '\0';			x			= strtol( code, NULL, 16 );			copy[y-1]	= x;			onchar		= false;			n			= 0;		} else {			copy[y]		= html[i];			y++;		}	}	copy[y] = '\0';	free( html );	return copy;}