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.

47 lines
1.3 KiB

  1. 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.
  2. <?
  3. $file = $argv[1];
  4. print $file;
  5. $fh = fopen($file, "r");
  6. while (!feof($fh)) {
  7. $text .= fread($fh, 8192);
  8. }
  9. fclose($fh);
  10. $text = convert_stupid_shit($text);
  11. $fh = fopen($file, "w");
  12. fwrite($fh, $text);
  13. fclose($fh);
  14. # functions
  15. function convert_stupid_shit($string)
  16. {
  17. $search = array(chr(145),
  18. chr(146),
  19. chr(147),
  20. chr(148),
  21. chr(151),
  22. chr(150),
  23. chr(153),
  24. chr(174));
  25. $replace = array("'",
  26. "'",
  27. '"',
  28. '"',
  29. '-',
  30. '-',
  31. '&trade;',
  32. '&reg;');
  33. return str_replace($search, $replace, $string);
  34. }
  35. ?>