xlpage-iso-8859-2.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php if (!defined('PmWiki')) exit();
  2. /* Copyright 2004-2017 Patrick R. Michaud (pmichaud@pobox.com)
  3. This file is part of PmWiki; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published
  5. by the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version. See pmwiki.php for full details.
  7. This file is used to enable the iso-8859-2 character set in PmWiki.
  8. The first part converts the charset to iso-8859-2 and removes
  9. conflicts for newline and keep tokens; the second part
  10. handles the conversion of pagenames from utf-8 (sent by browsers)
  11. into iso-8859-2 if needed.
  12. Script maintained by Petko YOTOV www.pmwiki.org/petko
  13. */
  14. global $HTTPHeaders, $pagename, $KeepToken, $Charset, $DefaultPageCharset;
  15. $HTTPHeaders[] = "Content-Type: text/html; charset=iso-8859-2";
  16. $Charset = "ISO-8859-2";
  17. SDVA($DefaultPageCharset, array('ISO-8859-1'=>$Charset));
  18. $KeepToken = "\263\263\263";
  19. $pagename = $_REQUEST['n'];
  20. if (!$pagename) $pagename = @$_GET['pagename'];
  21. if ($pagename=='' && $EnablePathInfo)
  22. $pagename = @substr($_SERVER['PATH_INFO'],1);
  23. if (!$pagename &&
  24. preg_match('!^'.preg_quote($_SERVER['SCRIPT_NAME'],'!').'/?([^?]*)!',
  25. $_SERVER['REQUEST_URI'],$match))
  26. $pagename = urldecode($match[1]);
  27. $pagename = preg_replace('!/+$!','',$pagename);
  28. if (!preg_match('/[\\x80-\\x9f]/', $pagename)) return;
  29. if (function_exists('iconv'))
  30. $pagename = iconv('UTF-8','ISO-8859-2',$pagename);
  31. else {
  32. $conv = array(
  33. ' '=>' ', 'Ä„'=>'¡', '˘'=>'¢', 'Å�'=>'£',
  34. '¤'=>'¤', 'Ľ'=>'¥', 'Åš'=>'¦', '§'=>'§',
  35. '¨'=>'¨', 'Å '=>'©', 'Åž'=>'ª', 'Ť'=>'«',
  36. 'Ź'=>'¬', '­'=>'­', 'Ž'=>'®', 'Å»'=>'¯',
  37. '°'=>'°', 'Ä…'=>'±', 'Ë›'=>'²', 'Å‚'=>'³',
  38. '´'=>'´', 'ľ'=>'µ', 'Å›'=>'¶', 'ˇ'=>'·',
  39. '¸'=>'¸', 'Å¡'=>'¹', 'ÅŸ'=>'º', 'Å¥'=>'»',
  40. 'ź'=>'¼', 'Ë�'=>'½', 'ž'=>'¾', 'ż'=>'¿',
  41. 'Å”'=>'À', 'Ã�'=>'Á', 'Â'=>'Â', 'Ä‚'=>'Ã',
  42. 'Ä'=>'Ä', 'Ĺ'=>'Å', 'Ć'=>'Æ', 'Ç'=>'Ç',
  43. 'ÄŒ'=>'È', 'É'=>'É', 'Ę'=>'Ê', 'Ë'=>'Ë',
  44. 'Äš'=>'Ì', 'Ã�'=>'Í', 'ÃŽ'=>'Î', 'ÄŽ'=>'Ï',
  45. 'Ä�'=>'Ð', 'Ń'=>'Ñ', 'Ň'=>'Ò', 'Ó'=>'Ó',
  46. 'Ô'=>'Ô', 'Å�'=>'Õ', 'Ö'=>'Ö', '×'=>'×',
  47. 'Ř'=>'Ø', 'Å®'=>'Ù', 'Ú'=>'Ú', 'Å°'=>'Û',
  48. 'Ãœ'=>'Ü', 'Ã�'=>'Ý', 'Å¢'=>'Þ', 'ß'=>'ß',
  49. 'Å•'=>'à', 'á'=>'á', 'â'=>'â', 'ă'=>'ã',
  50. 'ä'=>'ä', 'ĺ'=>'å', 'ć'=>'æ', 'ç'=>'ç',
  51. 'Ä�'=>'è', 'é'=>'é', 'Ä™'=>'ê', 'ë'=>'ë',
  52. 'Ä›'=>'ì', 'í'=>'í', 'î'=>'î', 'Ä�'=>'ï',
  53. 'Ä‘'=>'ð', 'Å„'=>'ñ', 'ň'=>'ò', 'ó'=>'ó',
  54. 'ô'=>'ô', 'Å‘'=>'õ', 'ö'=>'ö', '÷'=>'÷',
  55. 'Å™'=>'ø', 'ů'=>'ù', 'ú'=>'ú', 'ű'=>'û',
  56. 'ü'=>'ü', 'ý'=>'ý', 'Å£'=>'þ', 'Ë™'=>'ÿ',
  57. );
  58. $pagename = str_replace(array_keys($conv),array_values($conv),$pagename);
  59. }