From 720307d9ce09c85c3b6037fed985128b2bd860a4 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 23 Sep 2006 17:19:37 +0200 Subject: utf8_stripspecials optimization Add preconverted utf-8 string of special characters. The (once only) conversion of the special character unicode array into utf-8 occurs on every DokuWiki page view, irrespective of action or caching, and takes about one third of the time involved in delivering a wiki page straight from cache. The original unicode array has been left in place in the file to make any future amendments easier. darcs-hash:20060923151937-9b6ab-cae0340a95d9596415ef71d7b7e67ef9daca84ef.gz --- inc/utf8.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'inc/utf8.php') diff --git a/inc/utf8.php b/inc/utf8.php index dbf09b6fc..0479d8809 100644 --- a/inc/utf8.php +++ b/inc/utf8.php @@ -366,10 +366,12 @@ function utf8_romanize($string){ */ function utf8_stripspecials($string,$repl='',$additional=''){ global $UTF8_SPECIAL_CHARS; + global $UTF8_SPECIAL_CHARS2; static $specials = null; if(is_null($specials)){ - $specials = preg_quote(unicode_to_utf8($UTF8_SPECIAL_CHARS), '/'); +# $specials = preg_quote(unicode_to_utf8($UTF8_SPECIAL_CHARS), '/'); + $specials = preg_quote($UTF8_SPECIAL_CHARS2, '/'); } return preg_replace('/['.$additional.'\x00-\x19'.$specials.']/u',$repl,$string); @@ -988,6 +990,26 @@ $UTF8_SPECIAL_CHARS = array( 0xf8fb, 0xf8fc, 0xf8fd, 0xf8fe, 0xfe7c, 0xfe7d, ); +// utf8 version of above data +global $UTF8_SPECIAL_CHARS2; +$UTF8_SPECIAL_CHARS2 = + ' !"#$%&\'()+,/;<=>?@[\]^`{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•�'. + '�—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½�'. + '�¿×÷ˇ˘˙˚˛˜˝̣̀́̃̉΄΅·βφϑϒϕϖְֱֲֳִֵֶַָֹֻּֽ־ֿ�'. + '�ׁׂ׃׳״،؛؟ـًٌٍَُِّْ٪฿‌‍‎‏–—―‗‘’‚“”�'. + '��†‡•…‰′″‹›⁄₧₪₫€№℘™Ωℵ←↑→↓↔↕↵'. + '⇐⇑⇒⇓⇔∀∂∃∅∆∇∈∉∋∏∑−∕∗∙√∝∞∠∧∨�'. + '�∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌐⌠⌡〈〉⑩─�'. + '��┌┐└┘├┤┬┴┼═║╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠'. + '╡╢╣╤╥╦╧╨╩╪╫╬▀▄█▌▐░▒▓■▲▼◆◊●�'. + '�★☎☛☞♠♣♥♦✁✂✃✄✆✇✈✉✌✍✎✏✐✑✒✓✔✕�'. + '��✗✘✙✚✛✜✝✞✟✠✡✢✣✤✥✦✧✩✪✫✬✭✮✯✰✱'. + '✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋�'. + '�❏❐❑❒❖❘❙❚❛❜❝❞❡❢❣❤❥❦❧❿➉➓➔➘➙➚�'. + '��➜➝➞➟➠➡➢➣➤➥➦➧➨➩➪➫➬➭➮➯➱➲➳➴➵➶'. + '➷➸➹➺➻➼➽➾�'. + '�ﹼﹽ'; + /** * Romanization lookup table * -- cgit v1.2.3