From: Reini U. <ru...@x-...> - 2006-08-14 22:42:18
|
Mici Maci schrieb: > I tried to set the CHARSET in the config.ini to > 1) utf-8 > 2) iso-8859-2 > The 1) gone wrong because of a failed sql select. > [There's a mysql in the background.] the sql query > string should not contain utf encoded characters. of course you have to tell your database to accept utf-8. ALTER TABLE page DEFAULT CHARACTER SET utf8_general_ci; ALTER TABLE version DEFAULT CHARACTER SET utf8_general_ci; ALTER TABLE session DEFAULT CHARACTER SET utf8_general_ci; what we just do is telling the client talking to the database which charset we use for the transport. config.ini: CHARSET=UTF-8 => PearDB_mysql.php: SET NAMES 'utf8'; http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html > The number 2) was wrong because htmlspecialchars... So I > wrote a htmlspecialchars_workaround() function, that > checks the third argument (which is the requested charset), > and if it's 8859-2, it makes a few simple string replacement. > [<, > and & is enough to replace to "<", ">" and > "&"...] > It calls the original htmlspecialchars in other cases. > Now I can use iso-8859-2 in the config.ini, and Wiki > seems to work. Of course I have had to append > _workaround to all occurances os htmlspecialchars > in the original code. Brrrr! Ugly and impossible to > maintenance but maybe works... It's under testing > now. 8-) Well, why not. "_workaround" might be a bit too long though. > Why don't use PhpWiki developers their own html > escaper function?? htmlspecialchars() has more > disadvatages than advantages, because it keeps > the usable character set small, so excludes lots > of people from lots of nations to join the project... because you are the first with such an exotic eastern charset (czech and polish also) which is not supported by such a basic function. that tells us, that we seriously lack a lot of users. of course we accept any workaround function. > Reini Urban <ru...@x-...> írta: > >> Reini Urban schrieb: >>> Mici Maci schrieb: >>>> thanks for your answer but it's not so easy. PhpWiki >>>> uses htmlspecialchars() to masq strings, and PhpWiki >>>> passes a third argument to it containing the charset >>>> name. htmlspecialchars() does not know about latin2, >>>> it gives warnings. >>>> >>>> lib/XmlElement.php...: 502: Warning: htmlspecialchars(): >>>> charset `iso-8859-2' not supported, assuming iso-8859-1 >>>> >>>> lib/XmlElement.php...: 170: Warning: htmlspecialchars(): >>>> charset `iso-8859-2' not supported, assuming iso-8859-1 >>>> >>>> These two lines (502 and 170) are giving the message >>>> but lots of times in a page request. What's wrong? May >>>> I upgrade or reconfigure php to work, or the >>>> htmlspecialchars() function needs a workaround in >>>> PhpWiki? >>>> >>>> [phpwiki-1.3.12p3] >>>> [php-4.4.2-1.1] >>> Oje! >>> http://www.mantisbt.org/mantis/bug_view_page.php?bug_id=6624 >>> >>> So you have to convert to UTF-8 and bite into the bullet. >>> Note, that UTF-8 is not officially supported and not > included. >>> I posted a patch to the sf.net patch area, which should > get around most >>> issues. But since UTF-8 strings are asciiz-safe it is > not so harmful to >>> work without proper UTF-8 support in all string > functions. (preg_match, >>> strlen, ...) >> BTW: If you do have mbstring loaded in your php it's very > easy. >> Simply set >> mb_internal_encoding('UTF-8'); >> somewhere ("lib/config.ini") and set >> >> mbstring.func_overload in the php.ini or .htaccess to 7 >> >> .htaccess: >> php_value mbstring.func_overload 7 >> >> The hugepatch comes from the fact, that not all servers > support mbstring >> and strlen's are different in UTF-8 land. >> We do support now, input from UTF-8 land (e.g. MS IE), but > convert this >> input to our charset. -- Reini Urban http://phpwiki.org/ http://murbreak.at/ http://helsinki.at/ http://spacemovie.mur.at/ |