WalaWiki content from p1k3.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

48 lines
1.3 KiB

WareLogging. SourceCode. <[[Brennen]]> I don't know enough about weird charsets and weird extended characters, but lately I'm having to deal with them. Here is a useful PHP script, stolen somewhere or another and improvised slightly. Just feed it the filename you want to strip assorted stupid characters out of. And no, I don't actually recommend using PHP for this kind of thing - doubtless I should turn it into Perl.
<?
$file = $argv[1];
print $file;
$fh = fopen($file, "r");
while (!feof($fh)) {
$text .= fread($fh, 8192);
}
fclose($fh);
$text = convert_stupid_shit($text);
$fh = fopen($file, "w");
fwrite($fh, $text);
fclose($fh);
# functions
function convert_stupid_shit($string)
{
$search = array(chr(145),
chr(146),
chr(147),
chr(148),
chr(151),
chr(150),
chr(153),
chr(174));
$replace = array("'",
"'",
'"',
'"',
'-',
'-',
'&trade;',
'&reg;');
return str_replace($search, $replace, $string);
}
?>