| 1 |
<?php |
<?php |
| 2 |
// $Id: transliteration.inc,v 1.1.8.2 2009/06/07 19:06:01 smk Exp $ |
// $Id: transliteration.inc,v 1.1.8.3 2009/09/05 22:25:19 smk Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Sanitize a file name. |
* Sanitize a file name. |
| 6 |
* |
* |
| 7 |
* Transliterates the file name and removes all problematic characters. |
* Transliterates the file name and removes invalid characters. |
| 8 |
* |
* |
| 9 |
* @param string $filename |
* @param $filename |
| 10 |
* A file name. |
* A file name. |
| 11 |
* |
* |
| 12 |
* @return string |
* @return string |
| 28 |
} |
} |
| 29 |
|
|
| 30 |
/** |
/** |
| 31 |
* Transliterate UTF-8 input to plain ASCII. |
* Transliterate UTF-8 text to ASCII. |
| 32 |
* |
* |
| 33 |
* Based on Mediawiki's UtfNormal::quickIsNFCVerify(). |
* Based on Mediawiki's UtfNormal::quickIsNFCVerify(). |
| 34 |
* |
* |
| 35 |
* @param string $string |
* @param $string |
| 36 |
* UTF-8 text input. |
* UTF-8 text input. |
| 37 |
* @param string $unknown |
* @param $unknown |
| 38 |
* Replacement for unknown characters and illegal UTF-8 sequences. |
* Replacement string for characters that do not have a suitable ASCII |
| 39 |
* @param string $locale |
* equivalent. |
| 40 |
* Optional ISO 639 language code used to import language specific |
* @param $locale |
| 41 |
* replacements. Defaults to the current locale. |
* Optional ISO 639 language code that denotes the language of the input. |
| 42 |
* |
* Used to apply language-specific variations and defaults to the current |
| 43 |
* @return string |
* display language. If transliteration takes place during output (instead |
| 44 |
* Plain ASCII output. |
* of creation) and the source language is not known at that time, it is |
| 45 |
* @see transliteration_get() |
* recommended to set this argument to 'en' to produce consistent results |
| 46 |
|
* for all enabled languages. |
| 47 |
|
* @return |
| 48 |
|
* Transliterated text. |
| 49 |
*/ |
*/ |
| 50 |
function transliteration_process($string, $unknown = '?', $locale = NULL) { |
function transliteration_process($string, $unknown = '?', $locale = NULL) { |
| 51 |
// Screen out some characters that eg won't be allowed in XML. |
// Screen out some characters that eg won't be allowed in XML. |
| 189 |
} |
} |
| 190 |
|
|
| 191 |
/** |
/** |
| 192 |
* Lookup and replace a character from the transliteration database. |
* Load the transliteration database and replace a Unicode character. |
| 193 |
* |
* |
| 194 |
* @param integer $ord |
* @param $ord |
| 195 |
* A unicode ordinal character code. |
* A ordinal Unicode character code. |
| 196 |
* @param string $unknown |
* @param $unknown |
| 197 |
* Replacement for unknown characters. |
* Replacement string for characters that do not have a suitable ASCII |
| 198 |
* @param string $locale |
* equivalent. |
| 199 |
* Optional ISO 639 language code used to import language specific |
* @param $locale |
| 200 |
* replacements. Defaults to the current locale. |
* Optional ISO 639 language code that denotes the language of the input. |
| 201 |
* |
* Used to apply language-specific optimizations. Defaults to the current |
| 202 |
* @return string |
* display language. |
| 203 |
* Plain ASCII replacement character. |
* @return |
| 204 |
* @see transliteration_get() |
* ASCII replacement character. |
| 205 |
*/ |
*/ |
| 206 |
function _transliteration_replace($ord, $unknown = '?', $locale = NULL) { |
function _transliteration_replace($ord, $unknown = '?', $locale = NULL) { |
| 207 |
if (!isset($locale)) { |
if (!isset($locale)) { |