|
Cookbook /
As Spaced function in UTF-8Summary:How to fix the broken
{$Namespaced}, {$Titlespaced}, {$Groupspaced} when the website is in UTF-8Maintainer: Petko
Questions answered by this recipeHow to fix the broken Note that these fixes are available in PmWiki core as of version 2.2.0-beta30 (2007-02-09), so if you upgrade, your unicode website should be fine. DescriptionYou can use a custom In your config.php or farmconfig.php add the following code:
# you maybe have also one XLPage() call
include_once($FarmD.'/scripts/xlpage-utf-8.php');
# fix a bug in $CaseConversions (for pmwiki-2.2.0-beta16 and older)
$CaseConversions["\xc4\xb1"] = "\x49";
$CaseConversions["\xc5\xbf"] = "\x53";
# the new function
$AsSpacedFunction = 'AsSpacedUTF';
function AsSpacedUTF($text)
{
global $CaseConversions;
static $lower, $upper;
if(!@$CaseConversions) return AsSpaced($text);
if (!@$lower) {
$lower = implode('|', array_keys($CaseConversions));
$upper = implode('|', array_values($CaseConversions));
}
$text = preg_replace("/($lower|\\d)($upper)/", '$1 $2', $text);
$text = preg_replace('/(?<![-\\d])(\\d+( |$))/',' $1',$text);
return preg_replace("/($upper)(($upper)($lower|\\d))/",
'$1 $2', $text);
}
# A 'Page not found' variable redefined
$FmtPV['$RequestedPage'] = "'".htmlspecialchars($pagename, ENT_QUOTES)."'";
# a html header (for buggy browsers or when a page is saved to hdd)
$HTMLHeaderFmt['metacontent'] =
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
This should make You can vote for this function to be included in the PmWiki Core at PITS.00875. Other tipsSee UTF-8, the section was moved there. CommentsSee AlsoContributors |