Blob


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.
8 This file is used to enable the iso-8859-2 character set in PmWiki.
9 The first part converts the charset to iso-8859-2 and removes
10 conflicts for newline and keep tokens; the second part
11 handles the conversion of pagenames from utf-8 (sent by browsers)
12 into iso-8859-2 if needed.
14 Script maintained by Petko YOTOV www.pmwiki.org/petko
15 */
16 global $HTTPHeaders, $pagename, $KeepToken, $Charset, $DefaultPageCharset;
18 $HTTPHeaders[] = "Content-Type: text/html; charset=iso-8859-2";
19 $Charset = "ISO-8859-2";
20 SDVA($DefaultPageCharset, array('ISO-8859-1'=>$Charset));
22 $KeepToken = "\263\263\263";
24 $pagename = $_REQUEST['n'];
25 if (!$pagename) $pagename = @$_GET['pagename'];
26 if ($pagename=='' && $EnablePathInfo)
27 $pagename = @substr($_SERVER['PATH_INFO'],1);
28 if (!$pagename &&
29 preg_match('!^'.preg_quote($_SERVER['SCRIPT_NAME'],'!').'/?([^?]*)!',
30 $_SERVER['REQUEST_URI'],$match))
31 $pagename = urldecode($match[1]);
32 $pagename = preg_replace('!/+$!','',$pagename);
34 if (!preg_match('/[\\x80-\\x9f]/', $pagename)) return;
36 if (function_exists('iconv'))
37 $pagename = iconv('UTF-8','ISO-8859-2',$pagename);
38 else {
39 $conv = array(
40 ' '=>'', 'Ą'=>'', '˘'=>'', 'Ł'=>'',
41 '¤'=>'', 'Ľ'=>'', 'Ś'=>'', '§'=>'',
42 '¨'=>'', 'Š'=>'', 'Ş'=>'', 'Ť'=>'',
43 'Ź'=>'', '­'=>'', 'Ž'=>'', 'Ż'=>'',
44 '°'=>'', 'ą'=>'', '˛'=>'', 'ł'=>'',
45 '´'=>'', 'ľ'=>'', 'ś'=>'', 'ˇ'=>'',
46 '¸'=>'', 'š'=>'', 'ş'=>'', 'ť'=>'',
47 'ź'=>'', '˝'=>'', 'ž'=>'', 'ż'=>'',
48 'Ŕ'=>'', 'Á'=>'', 'Â'=>'', 'Ă'=>'',
49 'Ä'=>'', 'Ĺ'=>'', 'Ć'=>'', 'Ç'=>'',
50 'Č'=>'', 'É'=>'', 'Ę'=>'', 'Ë'=>'',
51 'Ě'=>'', 'Í'=>'', 'Î'=>'', 'Ď'=>'',
52 'Đ'=>'', 'Ń'=>'', 'Ň'=>'', 'Ó'=>'',
53 'Ô'=>'', 'Ő'=>'', 'Ö'=>'', '×'=>'',
54 'Ř'=>'', 'Ů'=>'', 'Ú'=>'', 'Ű'=>'',
55 'Ü'=>'', 'Ý'=>'', 'Ţ'=>'', 'ß'=>'',
56 'ŕ'=>'', 'á'=>'', 'â'=>'', 'ă'=>'',
57 'ä'=>'', 'ĺ'=>'', 'ć'=>'', 'ç'=>'',
58 'č'=>'', 'é'=>'', 'ę'=>'', 'ë'=>'',
59 'ě'=>'', 'í'=>'', 'î'=>'', 'ď'=>'',
60 'đ'=>'', 'ń'=>'', 'ň'=>'', 'ó'=>'',
61 'ô'=>'', 'ő'=>'', 'ö'=>'', '÷'=>'',
62 'ř'=>'', 'ů'=>'', 'ú'=>'', 'ű'=>'',
63 'ü'=>'', 'ý'=>'', 'ţ'=>'', '˙'=>'',
64 );
65 $pagename = str_replace(array_keys($conv),array_values($conv),$pagename);
66 }