readme
来自「php 开发的内容管理系统」· 代码 · 共 56 行
TXT
56 行
This directory contains some Unicode normalization routines. These routinesare meant to be reusable in other projects, so I'm not tying them to theMediaWiki utility functions.The main function to care about is UtfNormal::toNFC(); this will converta given UTF-8 string to Normalization Form C if it's not already such.The function assumes that the input string is already valid UTF-8; if thereare corrupt characters this may produce erroneous results.To also check for illegal characters, use UtfNormal::cleanUp(). This willstrip illegal UTF-8 sequences and characters that are illegal in XML, andif necessary convert to normalization form C.Performance is kind of stinky in absolute terms, though it should be speedyon pure ASCII text. ;) On text that can be determined quickly to already bein NFC it's not too awful but it can quickly get uncomfortably slow,particularly for Korean text (the hangul decomposition/composition code isextra slow).== Regenerating data tables ==UtfNormalData.inc and UtfNormalDataK.inc are generated from the UnicodeCharacter Database by the script UtfNormalGenerate.php. On a *nix system'make' should fetch the necessary files and regenerate it if the scriptshave been changed or you remove it.== Testing =='make test' will run the conformance test (UtfNormalTest.php), fetching thedata from from the net if necessary. If it reports failure, something isgoing wrong!== Benchmarks ==Run 'make bench' to download some sample texts from Wikipedia and run somecheap benchmarks of some of the functions. Take all numbers with largegrains of salt.== PHP module extension ==There's an experimental PHP extension module which wraps the ICU library'snormalization functions. This is *MUCH* faster than doing this work in purePHP code. This is in the 'normal' directory in MediaWiki's CVS extensionsmodule. It is known to work with PHP 4.3.8 and 5.0.2 on Linux/x86 but hasn'tbeen thoroughly tested on other configurations.If the php_normal.so module is loaded in php.ini, the normalization functionswill automatically use it. If you can't (or don't want to) load it in php.ini,you may be able to load it using the dl() function before include()ing orrequire()ing UtfNormal.php, and it will be picked up.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?