PageRenderTime 34ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 1ms

/includes/utf8/utf8.php

http://github.com/usebb/UseBB
PHP | 1210 lines | 704 code | 119 blank | 387 comment | 166 complexity | ab9d97799002699b40d06d9f73e7e975 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. namespace DokuWiki\UTF8;
  3. /**
  4. * UTF8 helper functions
  5. *
  6. * @license LGPL 2.1 (http://www.gnu.org/copyleft/lesser.html)
  7. * @author Andreas Gohr <andi@splitbrain.org>
  8. */
  9. /**
  10. * check for mb_string support
  11. */
  12. if(!defined('UTF8_MBSTRING')){
  13. if(function_exists('mb_substr') && !defined('UTF8_NOMBSTRING')){
  14. define('UTF8_MBSTRING',1);
  15. }else{
  16. define('UTF8_MBSTRING',0);
  17. }
  18. }
  19. if(UTF8_MBSTRING){ mb_internal_encoding('UTF-8'); }
  20. if(!function_exists('utf8_isASCII')){
  21. /**
  22. * Checks if a string contains 7bit ASCII only
  23. *
  24. * @author Andreas Haerter <andreas.haerter@dev.mail-node.com>
  25. */
  26. function utf8_isASCII($str){
  27. return (preg_match('/(?:[^\x00-\x7F])/', $str) !== 1);
  28. }
  29. }
  30. if(!function_exists('utf8_strip')){
  31. /**
  32. * Strips all highbyte chars
  33. *
  34. * Returns a pure ASCII7 string
  35. *
  36. * @author Andreas Gohr <andi@splitbrain.org>
  37. */
  38. function utf8_strip($str){
  39. $ascii = '';
  40. $len = strlen($str);
  41. for($i=0; $i<$len; $i++){
  42. if(ord($str{$i}) <128){
  43. $ascii .= $str{$i};
  44. }
  45. }
  46. return $ascii;
  47. }
  48. }
  49. if(!function_exists('utf8_check')){
  50. /**
  51. * Tries to detect if a string is in Unicode encoding
  52. *
  53. * @author <bmorel@ssi.fr>
  54. * @link http://www.php.net/manual/en/function.utf8-encode.php
  55. */
  56. function utf8_check($Str) {
  57. $len = strlen($Str);
  58. for ($i=0; $i<$len; $i++) {
  59. $b = ord($Str[$i]);
  60. if ($b < 0x80) continue; # 0bbbbbbb
  61. elseif (($b & 0xE0) == 0xC0) $n=1; # 110bbbbb
  62. elseif (($b & 0xF0) == 0xE0) $n=2; # 1110bbbb
  63. elseif (($b & 0xF8) == 0xF0) $n=3; # 11110bbb
  64. elseif (($b & 0xFC) == 0xF8) $n=4; # 111110bb
  65. elseif (($b & 0xFE) == 0xFC) $n=5; # 1111110b
  66. else return false; # Does not match any model
  67. for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
  68. if ((++$i == $len) || ((ord($Str[$i]) & 0xC0) != 0x80))
  69. return false;
  70. }
  71. }
  72. return true;
  73. }
  74. }
  75. if(!function_exists('utf8_strlen')){
  76. /**
  77. * Unicode aware replacement for strlen()
  78. *
  79. * utf8_decode() converts characters that are not in ISO-8859-1
  80. * to '?', which, for the purpose of counting, is alright - It's
  81. * even faster than mb_strlen.
  82. *
  83. * @author <chernyshevsky at hotmail dot com>
  84. * @see strlen()
  85. * @see utf8_decode()
  86. */
  87. function utf8_strlen($string){
  88. return strlen(utf8_decode($string));
  89. }
  90. }
  91. if(!function_exists('utf8_substr')){
  92. /**
  93. * UTF-8 aware alternative to substr
  94. *
  95. * Return part of a string given character offset (and optionally length)
  96. *
  97. * @author Harry Fuecks <hfuecks@gmail.com>
  98. * @author Chris Smith <chris@jalakai.co.uk>
  99. * @param string
  100. * @param integer number of UTF-8 characters offset (from left)
  101. * @param integer (optional) length in UTF-8 characters from offset
  102. * @return mixed string or false if failure
  103. */
  104. function utf8_substr($str, $offset, $length = null) {
  105. if(UTF8_MBSTRING){
  106. if( $length === null ){
  107. return mb_substr($str, $offset);
  108. }else{
  109. return mb_substr($str, $offset, $length);
  110. }
  111. }
  112. /*
  113. * Notes:
  114. *
  115. * no mb string support, so we'll use pcre regex's with 'u' flag
  116. * pcre only supports repetitions of less than 65536, in order to accept up to MAXINT values for
  117. * offset and length, we'll repeat a group of 65535 characters when needed (ok, up to MAXINT-65536)
  118. *
  119. * substr documentation states false can be returned in some cases (e.g. offset > string length)
  120. * mb_substr never returns false, it will return an empty string instead.
  121. *
  122. * calculating the number of characters in the string is a relatively expensive operation, so
  123. * we only carry it out when necessary. It isn't necessary for +ve offsets and no specified length
  124. */
  125. // cast parameters to appropriate types to avoid multiple notices/warnings
  126. $str = (string)$str; // generates E_NOTICE for PHP4 objects, but not PHP5 objects
  127. $offset = (int)$offset;
  128. if (!is_null($length)) $length = (int)$length;
  129. // handle trivial cases
  130. if ($length === 0) return '';
  131. if ($offset < 0 && $length < 0 && $length < $offset) return '';
  132. $offset_pattern = '';
  133. $length_pattern = '';
  134. // normalise -ve offsets (we could use a tail anchored pattern, but they are horribly slow!)
  135. if ($offset < 0) {
  136. $strlen = strlen(utf8_decode($str)); // see notes
  137. $offset = $strlen + $offset;
  138. if ($offset < 0) $offset = 0;
  139. }
  140. // establish a pattern for offset, a non-captured group equal in length to offset
  141. if ($offset > 0) {
  142. $Ox = (int)($offset/65535);
  143. $Oy = $offset%65535;
  144. if ($Ox) $offset_pattern = '(?:.{65535}){'.$Ox.'}';
  145. $offset_pattern = '^(?:'.$offset_pattern.'.{'.$Oy.'})';
  146. } else {
  147. $offset_pattern = '^'; // offset == 0; just anchor the pattern
  148. }
  149. // establish a pattern for length
  150. if (is_null($length)) {
  151. $length_pattern = '(.*)$'; // the rest of the string
  152. } else {
  153. if (!isset($strlen)) $strlen = strlen(utf8_decode($str)); // see notes
  154. if ($offset > $strlen) return ''; // another trivial case
  155. if ($length > 0) {
  156. $length = min($strlen-$offset, $length); // reduce any length that would go passed the end of the string
  157. $Lx = (int)($length/65535);
  158. $Ly = $length%65535;
  159. // +ve length requires ... a captured group of length characters
  160. if ($Lx) $length_pattern = '(?:.{65535}){'.$Lx.'}';
  161. $length_pattern = '('.$length_pattern.'.{'.$Ly.'})';
  162. } else if ($length < 0) {
  163. if ($length < ($offset - $strlen)) return '';
  164. $Lx = (int)((-$length)/65535);
  165. $Ly = (-$length)%65535;
  166. // -ve length requires ... capture everything except a group of -length characters
  167. // anchored at the tail-end of the string
  168. if ($Lx) $length_pattern = '(?:.{65535}){'.$Lx.'}';
  169. $length_pattern = '(.*)(?:'.$length_pattern.'.{'.$Ly.'})$';
  170. }
  171. }
  172. if (!preg_match('#'.$offset_pattern.$length_pattern.'#us',$str,$match)) return '';
  173. return $match[1];
  174. }
  175. }
  176. if(!function_exists('utf8_substr_replace')){
  177. /**
  178. * Unicode aware replacement for substr_replace()
  179. *
  180. * @author Andreas Gohr <andi@splitbrain.org>
  181. * @see substr_replace()
  182. */
  183. function utf8_substr_replace($string, $replacement, $start , $length=0 ){
  184. $ret = '';
  185. if($start>0) $ret .= utf8_substr($string, 0, $start);
  186. $ret .= $replacement;
  187. $ret .= utf8_substr($string, $start+$length);
  188. return $ret;
  189. }
  190. }
  191. if(!function_exists('utf8_ltrim')){
  192. /**
  193. * Unicode aware replacement for ltrim()
  194. *
  195. * @author Andreas Gohr <andi@splitbrain.org>
  196. * @see ltrim()
  197. * @return string
  198. */
  199. function utf8_ltrim($str,$charlist=''){
  200. if($charlist == '') return ltrim($str);
  201. //quote charlist for use in a characterclass
  202. $charlist = preg_replace('!([\\\\\\-\\]\\[/])!','\\\${1}',$charlist);
  203. return preg_replace('/^['.$charlist.']+/u','',$str);
  204. }
  205. }
  206. if(!function_exists('utf8_rtrim')){
  207. /**
  208. * Unicode aware replacement for rtrim()
  209. *
  210. * @author Andreas Gohr <andi@splitbrain.org>
  211. * @see rtrim()
  212. * @return string
  213. */
  214. function utf8_rtrim($str,$charlist=''){
  215. if($charlist == '') return rtrim($str);
  216. //quote charlist for use in a characterclass
  217. $charlist = preg_replace('!([\\\\\\-\\]\\[/])!','\\\${1}',$charlist);
  218. return preg_replace('/['.$charlist.']+$/u','',$str);
  219. }
  220. }
  221. if(!function_exists('utf8_trim')){
  222. /**
  223. * Unicode aware replacement for trim()
  224. *
  225. * @author Andreas Gohr <andi@splitbrain.org>
  226. * @see trim()
  227. * @return string
  228. */
  229. function utf8_trim($str,$charlist='') {
  230. if($charlist == '') return trim($str);
  231. return utf8_ltrim(utf8_rtrim($str,$charlist),$charlist);
  232. }
  233. }
  234. if(!function_exists('utf8_strtolower')){
  235. /**
  236. * This is a unicode aware replacement for strtolower()
  237. *
  238. * Uses mb_string extension if available
  239. *
  240. * @author Leo Feyer <leo@typolight.org>
  241. * @see strtolower()
  242. * @see utf8_strtoupper()
  243. */
  244. function utf8_strtolower($string){
  245. if(UTF8_MBSTRING) return mb_strtolower($string,'utf-8');
  246. global $UTF8_UPPER_TO_LOWER;
  247. return strtr($string,$UTF8_UPPER_TO_LOWER);
  248. }
  249. }
  250. if(!function_exists('utf8_strtoupper')){
  251. /**
  252. * This is a unicode aware replacement for strtoupper()
  253. *
  254. * Uses mb_string extension if available
  255. *
  256. * @author Leo Feyer <leo@typolight.org>
  257. * @see strtoupper()
  258. * @see utf8_strtoupper()
  259. */
  260. function utf8_strtoupper($string){
  261. if(UTF8_MBSTRING) return mb_strtoupper($string,'utf-8');
  262. global $UTF8_LOWER_TO_UPPER;
  263. return strtr($string,$UTF8_LOWER_TO_UPPER);
  264. }
  265. }
  266. if(!function_exists('utf8_ucfirst')){
  267. /**
  268. * UTF-8 aware alternative to ucfirst
  269. * Make a string's first character uppercase
  270. *
  271. * @author Harry Fuecks
  272. * @param string
  273. * @return string with first character as upper case (if applicable)
  274. */
  275. function utf8_ucfirst($str){
  276. switch ( utf8_strlen($str) ) {
  277. case 0:
  278. return '';
  279. case 1:
  280. return utf8_strtoupper($str);
  281. default:
  282. preg_match('/^(.{1})(.*)$/us', $str, $matches);
  283. return utf8_strtoupper($matches[1]).$matches[2];
  284. }
  285. }
  286. }
  287. if(!function_exists('utf8_ucwords')){
  288. /**
  289. * UTF-8 aware alternative to ucwords
  290. * Uppercase the first character of each word in a string
  291. *
  292. * @author Harry Fuecks
  293. * @param string
  294. * @return string with first char of each word uppercase
  295. * @see http://www.php.net/ucwords
  296. */
  297. function utf8_ucwords($str) {
  298. // Note: [\x0c\x09\x0b\x0a\x0d\x20] matches;
  299. // form feeds, horizontal tabs, vertical tabs, linefeeds and carriage returns
  300. // This corresponds to the definition of a "word" defined at http://www.php.net/ucwords
  301. $pattern = '/(^|([\x0c\x09\x0b\x0a\x0d\x20]+))([^\x0c\x09\x0b\x0a\x0d\x20]{1})[^\x0c\x09\x0b\x0a\x0d\x20]*/u';
  302. return preg_replace_callback($pattern, 'DokuWiki\UTF8\utf8_ucwords_callback',$str);
  303. }
  304. /**
  305. * Callback function for preg_replace_callback call in utf8_ucwords
  306. * You don't need to call this yourself
  307. *
  308. * @author Harry Fuecks
  309. * @param array of matches corresponding to a single word
  310. * @return string with first char of the word in uppercase
  311. * @see utf8_ucwords
  312. * @see utf8_strtoupper
  313. */
  314. function utf8_ucwords_callback($matches) {
  315. $leadingws = $matches[2];
  316. $ucfirst = utf8_strtoupper($matches[3]);
  317. $ucword = utf8_substr_replace(ltrim($matches[0]),$ucfirst,0,1);
  318. return $leadingws . $ucword;
  319. }
  320. }
  321. if(!function_exists('utf8_deaccent')){
  322. /**
  323. * Replace accented UTF-8 characters by unaccented ASCII-7 equivalents
  324. *
  325. * Use the optional parameter to just deaccent lower ($case = -1) or upper ($case = 1)
  326. * letters. Default is to deaccent both cases ($case = 0)
  327. *
  328. * @author Andreas Gohr <andi@splitbrain.org>
  329. */
  330. function utf8_deaccent($string,$case=0){
  331. if($case <= 0){
  332. global $UTF8_LOWER_ACCENTS;
  333. $string = strtr($string,$UTF8_LOWER_ACCENTS);
  334. }
  335. if($case >= 0){
  336. global $UTF8_UPPER_ACCENTS;
  337. $string = strtr($string,$UTF8_UPPER_ACCENTS);
  338. }
  339. return $string;
  340. }
  341. }
  342. if(!function_exists('utf8_romanize')){
  343. /**
  344. * Romanize a non-latin string
  345. *
  346. * @author Andreas Gohr <andi@splitbrain.org>
  347. */
  348. function utf8_romanize($string){
  349. if(utf8_isASCII($string)) return $string; //nothing to do
  350. global $UTF8_ROMANIZATION;
  351. return strtr($string,$UTF8_ROMANIZATION);
  352. }
  353. }
  354. if(!function_exists('utf8_stripspecials')){
  355. /**
  356. * Removes special characters (nonalphanumeric) from a UTF-8 string
  357. *
  358. * This function adds the controlchars 0x00 to 0x19 to the array of
  359. * stripped chars (they are not included in $UTF8_SPECIAL_CHARS)
  360. *
  361. * @author Andreas Gohr <andi@splitbrain.org>
  362. * @param string $string The UTF8 string to strip of special chars
  363. * @param string $repl Replace special with this string
  364. * @param string $additional Additional chars to strip (used in regexp char class)
  365. */
  366. function utf8_stripspecials($string,$repl='',$additional=''){
  367. global $UTF8_SPECIAL_CHARS;
  368. global $UTF8_SPECIAL_CHARS2;
  369. static $specials = null;
  370. if(is_null($specials)){
  371. #$specials = preg_quote(unicode_to_utf8($UTF8_SPECIAL_CHARS), '/');
  372. $specials = preg_quote($UTF8_SPECIAL_CHARS2, '/');
  373. }
  374. return preg_replace('/['.$additional.'\x00-\x19'.$specials.']/u',$repl,$string);
  375. }
  376. }
  377. if(!function_exists('utf8_strpos')){
  378. /**
  379. * This is an Unicode aware replacement for strpos
  380. *
  381. * @author Leo Feyer <leo@typolight.org>
  382. * @see strpos()
  383. * @param string
  384. * @param string
  385. * @param integer
  386. * @return integer
  387. */
  388. function utf8_strpos($haystack, $needle, $offset=0){
  389. $comp = 0;
  390. $length = null;
  391. while (is_null($length) || $length < $offset) {
  392. $pos = strpos($haystack, $needle, $offset + $comp);
  393. if ($pos === false)
  394. return false;
  395. $length = utf8_strlen(substr($haystack, 0, $pos));
  396. if ($length < $offset)
  397. $comp = $pos - $length;
  398. }
  399. return $length;
  400. }
  401. }
  402. if(!function_exists('utf8_tohtml')){
  403. /**
  404. * Encodes UTF-8 characters to HTML entities
  405. *
  406. * @author Tom N Harris <tnharris@whoopdedo.org>
  407. * @author <vpribish at shopping dot com>
  408. * @link http://www.php.net/manual/en/function.utf8-decode.php
  409. */
  410. function utf8_tohtml ($str) {
  411. $ret = '';
  412. foreach (utf8_to_unicode($str) as $cp) {
  413. if ($cp < 0x80)
  414. $ret .= chr($cp);
  415. elseif ($cp < 0x100)
  416. $ret .= "&#$cp;";
  417. else
  418. $ret .= '&#x'.dechex($cp).';';
  419. }
  420. return $ret;
  421. }
  422. }
  423. if(!function_exists('utf8_unhtml')){
  424. /**
  425. * Decodes HTML entities to UTF-8 characters
  426. *
  427. * Convert any &#..; entity to a codepoint,
  428. * The entities flag defaults to only decoding numeric entities.
  429. * Pass HTML_ENTITIES and named entities, including &amp; &lt; etc.
  430. * are handled as well. Avoids the problem that would occur if you
  431. * had to decode "&amp;#38;&#38;amp;#38;"
  432. *
  433. * unhtmlspecialchars(utf8_unhtml($s)) -> "&#38;&#38;"
  434. * utf8_unhtml(unhtmlspecialchars($s)) -> "&&amp#38;"
  435. * what it should be -> "&#38;&amp#38;"
  436. *
  437. * @author Tom N Harris <tnharris@whoopdedo.org>
  438. * @param string $str UTF-8 encoded string
  439. * @param boolean $entities Flag controlling decoding of named entities.
  440. * @return UTF-8 encoded string with numeric (and named) entities replaced.
  441. */
  442. function utf8_unhtml($str, $entities=null) {
  443. static $decoder = null;
  444. if (is_null($decoder))
  445. $decoder = new utf8_entity_decoder();
  446. if (is_null($entities))
  447. return preg_replace_callback('/(&#([Xx])?([0-9A-Za-z]+);)/m',
  448. 'DokuWiki\UTF8\utf8_decode_numeric', $str);
  449. else
  450. return preg_replace_callback('/&(#)?([Xx])?([0-9A-Za-z]+);/m',
  451. array(&$decoder, 'decode'), $str);
  452. }
  453. }
  454. if(!function_exists('utf8_decode_numeric')){
  455. function utf8_decode_numeric($ent) {
  456. switch ($ent[2]) {
  457. case 'X':
  458. case 'x':
  459. $cp = hexdec($ent[3]);
  460. break;
  461. default:
  462. $cp = intval($ent[3]);
  463. break;
  464. }
  465. return unicode_to_utf8(array($cp));
  466. }
  467. }
  468. if(!class_exists('utf8_entity_decoder')){
  469. class utf8_entity_decoder {
  470. var $table;
  471. function utf8_entity_decoder() {
  472. $table = get_html_translation_table(HTML_ENTITIES);
  473. $table = array_flip($table);
  474. $this->table = array_map(array(&$this,'makeutf8'), $table);
  475. }
  476. function makeutf8($c) {
  477. return unicode_to_utf8(array(ord($c)));
  478. }
  479. function decode($ent) {
  480. if ($ent[1] == '#') {
  481. return utf8_decode_numeric($ent);
  482. } elseif (array_key_exists($ent[0],$this->table)) {
  483. return $this->table[$ent[0]];
  484. } else {
  485. return $ent[0];
  486. }
  487. }
  488. }
  489. }
  490. if(!function_exists('utf8_to_unicode')){
  491. /**
  492. * Takes an UTF-8 string and returns an array of ints representing the
  493. * Unicode characters. Astral planes are supported ie. the ints in the
  494. * output can be > 0xFFFF. Occurrances of the BOM are ignored. Surrogates
  495. * are not allowed.
  496. *
  497. * If $strict is set to true the function returns false if the input
  498. * string isn't a valid UTF-8 octet sequence and raises a PHP error at
  499. * level E_USER_WARNING
  500. *
  501. * Note: this function has been modified slightly in this library to
  502. * trigger errors on encountering bad bytes
  503. *
  504. * @author <hsivonen@iki.fi>
  505. * @author Harry Fuecks <hfuecks@gmail.com>
  506. * @param string UTF-8 encoded string
  507. * @param boolean Check for invalid sequences?
  508. * @return mixed array of unicode code points or false if UTF-8 invalid
  509. * @see unicode_to_utf8
  510. * @link http://hsivonen.iki.fi/php-utf8/
  511. * @link http://sourceforge.net/projects/phputf8/
  512. */
  513. function utf8_to_unicode($str,$strict=false) {
  514. $mState = 0; // cached expected number of octets after the current octet
  515. // until the beginning of the next UTF8 character sequence
  516. $mUcs4 = 0; // cached Unicode character
  517. $mBytes = 1; // cached expected number of octets in the current sequence
  518. $out = array();
  519. $len = strlen($str);
  520. for($i = 0; $i < $len; $i++) {
  521. $in = ord($str{$i});
  522. if ( $mState == 0) {
  523. // When mState is zero we expect either a US-ASCII character or a
  524. // multi-octet sequence.
  525. if (0 == (0x80 & ($in))) {
  526. // US-ASCII, pass straight through.
  527. $out[] = $in;
  528. $mBytes = 1;
  529. } else if (0xC0 == (0xE0 & ($in))) {
  530. // First octet of 2 octet sequence
  531. $mUcs4 = ($in);
  532. $mUcs4 = ($mUcs4 & 0x1F) << 6;
  533. $mState = 1;
  534. $mBytes = 2;
  535. } else if (0xE0 == (0xF0 & ($in))) {
  536. // First octet of 3 octet sequence
  537. $mUcs4 = ($in);
  538. $mUcs4 = ($mUcs4 & 0x0F) << 12;
  539. $mState = 2;
  540. $mBytes = 3;
  541. } else if (0xF0 == (0xF8 & ($in))) {
  542. // First octet of 4 octet sequence
  543. $mUcs4 = ($in);
  544. $mUcs4 = ($mUcs4 & 0x07) << 18;
  545. $mState = 3;
  546. $mBytes = 4;
  547. } else if (0xF8 == (0xFC & ($in))) {
  548. /* First octet of 5 octet sequence.
  549. *
  550. * This is illegal because the encoded codepoint must be either
  551. * (a) not the shortest form or
  552. * (b) outside the Unicode range of 0-0x10FFFF.
  553. * Rather than trying to resynchronize, we will carry on until the end
  554. * of the sequence and let the later error handling code catch it.
  555. */
  556. $mUcs4 = ($in);
  557. $mUcs4 = ($mUcs4 & 0x03) << 24;
  558. $mState = 4;
  559. $mBytes = 5;
  560. } else if (0xFC == (0xFE & ($in))) {
  561. // First octet of 6 octet sequence, see comments for 5 octet sequence.
  562. $mUcs4 = ($in);
  563. $mUcs4 = ($mUcs4 & 1) << 30;
  564. $mState = 5;
  565. $mBytes = 6;
  566. } elseif($strict) {
  567. /* Current octet is neither in the US-ASCII range nor a legal first
  568. * octet of a multi-octet sequence.
  569. */
  570. trigger_error(
  571. 'utf8_to_unicode: Illegal sequence identifier '.
  572. 'in UTF-8 at byte '.$i,
  573. E_USER_WARNING
  574. );
  575. return false;
  576. }
  577. } else {
  578. // When mState is non-zero, we expect a continuation of the multi-octet
  579. // sequence
  580. if (0x80 == (0xC0 & ($in))) {
  581. // Legal continuation.
  582. $shift = ($mState - 1) * 6;
  583. $tmp = $in;
  584. $tmp = ($tmp & 0x0000003F) << $shift;
  585. $mUcs4 |= $tmp;
  586. /**
  587. * End of the multi-octet sequence. mUcs4 now contains the final
  588. * Unicode codepoint to be output
  589. */
  590. if (0 == --$mState) {
  591. /*
  592. * Check for illegal sequences and codepoints.
  593. */
  594. // From Unicode 3.1, non-shortest form is illegal
  595. if (((2 == $mBytes) && ($mUcs4 < 0x0080)) ||
  596. ((3 == $mBytes) && ($mUcs4 < 0x0800)) ||
  597. ((4 == $mBytes) && ($mUcs4 < 0x10000)) ||
  598. (4 < $mBytes) ||
  599. // From Unicode 3.2, surrogate characters are illegal
  600. (($mUcs4 & 0xFFFFF800) == 0xD800) ||
  601. // Codepoints outside the Unicode range are illegal
  602. ($mUcs4 > 0x10FFFF)) {
  603. if($strict){
  604. trigger_error(
  605. 'utf8_to_unicode: Illegal sequence or codepoint '.
  606. 'in UTF-8 at byte '.$i,
  607. E_USER_WARNING
  608. );
  609. return false;
  610. }
  611. }
  612. if (0xFEFF != $mUcs4) {
  613. // BOM is legal but we don't want to output it
  614. $out[] = $mUcs4;
  615. }
  616. //initialize UTF8 cache
  617. $mState = 0;
  618. $mUcs4 = 0;
  619. $mBytes = 1;
  620. }
  621. } elseif($strict) {
  622. /**
  623. *((0xC0 & (*in) != 0x80) && (mState != 0))
  624. * Incomplete multi-octet sequence.
  625. */
  626. trigger_error(
  627. 'utf8_to_unicode: Incomplete multi-octet '.
  628. ' sequence in UTF-8 at byte '.$i,
  629. E_USER_WARNING
  630. );
  631. return false;
  632. }
  633. }
  634. }
  635. return $out;
  636. }
  637. }
  638. if(!function_exists('unicode_to_utf8')){
  639. /**
  640. * Takes an array of ints representing the Unicode characters and returns
  641. * a UTF-8 string. Astral planes are supported ie. the ints in the
  642. * input can be > 0xFFFF. Occurrances of the BOM are ignored. Surrogates
  643. * are not allowed.
  644. *
  645. * If $strict is set to true the function returns false if the input
  646. * array contains ints that represent surrogates or are outside the
  647. * Unicode range and raises a PHP error at level E_USER_WARNING
  648. *
  649. * Note: this function has been modified slightly in this library to use
  650. * output buffering to concatenate the UTF-8 string (faster) as well as
  651. * reference the array by it's keys
  652. *
  653. * @param array of unicode code points representing a string
  654. * @param boolean Check for invalid sequences?
  655. * @return mixed UTF-8 string or false if array contains invalid code points
  656. * @author <hsivonen@iki.fi>
  657. * @author Harry Fuecks <hfuecks@gmail.com>
  658. * @see utf8_to_unicode
  659. * @link http://hsivonen.iki.fi/php-utf8/
  660. * @link http://sourceforge.net/projects/phputf8/
  661. */
  662. function unicode_to_utf8($arr,$strict=false) {
  663. if (!is_array($arr)) return '';
  664. ob_start();
  665. foreach (array_keys($arr) as $k) {
  666. if ( ($arr[$k] >= 0) && ($arr[$k] <= 0x007f) ) {
  667. # ASCII range (including control chars)
  668. echo chr($arr[$k]);
  669. } else if ($arr[$k] <= 0x07ff) {
  670. # 2 byte sequence
  671. echo chr(0xc0 | ($arr[$k] >> 6));
  672. echo chr(0x80 | ($arr[$k] & 0x003f));
  673. } else if($arr[$k] == 0xFEFF) {
  674. # Byte order mark (skip)
  675. // nop -- zap the BOM
  676. } else if ($arr[$k] >= 0xD800 && $arr[$k] <= 0xDFFF) {
  677. # Test for illegal surrogates
  678. // found a surrogate
  679. if($strict){
  680. trigger_error(
  681. 'unicode_to_utf8: Illegal surrogate '.
  682. 'at index: '.$k.', value: '.$arr[$k],
  683. E_USER_WARNING
  684. );
  685. return false;
  686. }
  687. } else if ($arr[$k] <= 0xffff) {
  688. # 3 byte sequence
  689. echo chr(0xe0 | ($arr[$k] >> 12));
  690. echo chr(0x80 | (($arr[$k] >> 6) & 0x003f));
  691. echo chr(0x80 | ($arr[$k] & 0x003f));
  692. } else if ($arr[$k] <= 0x10ffff) {
  693. # 4 byte sequence
  694. echo chr(0xf0 | ($arr[$k] >> 18));
  695. echo chr(0x80 | (($arr[$k] >> 12) & 0x3f));
  696. echo chr(0x80 | (($arr[$k] >> 6) & 0x3f));
  697. echo chr(0x80 | ($arr[$k] & 0x3f));
  698. } elseif($strict) {
  699. trigger_error(
  700. 'unicode_to_utf8: Codepoint out of Unicode range '.
  701. 'at index: '.$k.', value: '.$arr[$k],
  702. E_USER_WARNING
  703. );
  704. // out of range
  705. return false;
  706. }
  707. }
  708. $result = ob_get_contents();
  709. ob_end_clean();
  710. return $result;
  711. }
  712. }
  713. if(!function_exists('utf8_to_utf16be')){
  714. /**
  715. * UTF-8 to UTF-16BE conversion.
  716. *
  717. * Maybe really UCS-2 without mb_string due to utf8_to_unicode limits
  718. */
  719. function utf8_to_utf16be(&$str, $bom = false) {
  720. $out = $bom ? "\xFE\xFF" : '';
  721. if(UTF8_MBSTRING) return $out.mb_convert_encoding($str,'UTF-16BE','UTF-8');
  722. $uni = utf8_to_unicode($str);
  723. foreach($uni as $cp){
  724. $out .= pack('n',$cp);
  725. }
  726. return $out;
  727. }
  728. }
  729. if(!function_exists('utf16be_to_utf8')){
  730. /**
  731. * UTF-8 to UTF-16BE conversion.
  732. *
  733. * Maybe really UCS-2 without mb_string due to utf8_to_unicode limits
  734. */
  735. function utf16be_to_utf8(&$str) {
  736. $uni = unpack('n*',$str);
  737. return unicode_to_utf8($uni);
  738. }
  739. }
  740. if(!function_exists('utf8_bad_replace')){
  741. /**
  742. * Replace bad bytes with an alternative character
  743. *
  744. * ASCII character is recommended for replacement char
  745. *
  746. * PCRE Pattern to locate bad bytes in a UTF-8 string
  747. * Comes from W3 FAQ: Multilingual Forms
  748. * Note: modified to include full ASCII range including control chars
  749. *
  750. * @author Harry Fuecks <hfuecks@gmail.com>
  751. * @see http://www.w3.org/International/questions/qa-forms-utf-8
  752. * @param string to search
  753. * @param string to replace bad bytes with (defaults to '?') - use ASCII
  754. * @return string
  755. */
  756. function utf8_bad_replace($str, $replace = '') {
  757. $UTF8_BAD =
  758. '([\x00-\x7F]'. # ASCII (including control chars)
  759. '|[\xC2-\xDF][\x80-\xBF]'. # non-overlong 2-byte
  760. '|\xE0[\xA0-\xBF][\x80-\xBF]'. # excluding overlongs
  761. '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. # straight 3-byte
  762. '|\xED[\x80-\x9F][\x80-\xBF]'. # excluding surrogates
  763. '|\xF0[\x90-\xBF][\x80-\xBF]{2}'. # planes 1-3
  764. '|[\xF1-\xF3][\x80-\xBF]{3}'. # planes 4-15
  765. '|\xF4[\x80-\x8F][\x80-\xBF]{2}'. # plane 16
  766. '|(.{1}))'; # invalid byte
  767. ob_start();
  768. while (preg_match('/'.$UTF8_BAD.'/S', $str, $matches)) {
  769. if ( !isset($matches[2])) {
  770. echo $matches[0];
  771. } else {
  772. echo $replace;
  773. }
  774. $str = substr($str,strlen($matches[0]));
  775. }
  776. $result = ob_get_contents();
  777. ob_end_clean();
  778. return $result;
  779. }
  780. }
  781. if(!function_exists('utf8_correctIdx')){
  782. /**
  783. * adjust a byte index into a utf8 string to a utf8 character boundary
  784. *
  785. * @param $str string utf8 character string
  786. * @param $i int byte index into $str
  787. * @param $next bool direction to search for boundary,
  788. * false = up (current character)
  789. * true = down (next character)
  790. *
  791. * @return int byte index into $str now pointing to a utf8 character boundary
  792. *
  793. * @author chris smith <chris@jalakai.co.uk>
  794. */
  795. function utf8_correctIdx(&$str,$i,$next=false) {
  796. if ($i <= 0) return 0;
  797. $limit = strlen($str);
  798. if ($i>=$limit) return $limit;
  799. if ($next) {
  800. while (($i<$limit) && ((ord($str[$i]) & 0xC0) == 0x80)) $i++;
  801. } else {
  802. while ($i && ((ord($str[$i]) & 0xC0) == 0x80)) $i--;
  803. }
  804. return $i;
  805. }
  806. }
  807. // only needed if no mb_string available
  808. if(!UTF8_MBSTRING){
  809. /**
  810. * UTF-8 Case lookup table
  811. *
  812. * This lookuptable defines the upper case letters to their correspponding
  813. * lower case letter in UTF-8
  814. *
  815. * @author Andreas Gohr <andi@splitbrain.org>
  816. */
  817. global $UTF8_LOWER_TO_UPPER;
  818. if(empty($UTF8_LOWER_TO_UPPER)) $UTF8_LOWER_TO_UPPER = array(
  819. "??&#x161;"=>"???","??&#x2122;"=>"??š","??&#x2DC;"=>"??¸","??&#x2014;"=>"???","??&#x2013;"=>"???","??&#x2022;"=>"???","??&#x201D;"=>"??´","??&#x201C;"=>"???","??&#x2019;"=>"???","??&#x2018;"=>"???",
  820. "???"=>"??°","???"=>"???","??&#x17D;"=>"??Ž","???"=>"??­","??&#x152;"=>"???","??&#x2039;"=>"???","??&#x160;"=>"???","??&#x2030;"=>"??Š","??&#x2C6;"=>"??¨","??&#x2021;"=>"??§",
  821. "??&#x2020;"=>"???","??&#x2026;"=>"???","??&#x201E;"=>"??¤","??&#x192;"=>"???","??&#x201A;"=>"???","?? "=>"???","á??"=>"á??","á??"=>"á??","á??"=>"á?Š","á?&#x2018;"=>"á?&#x2122;",
  822. "á??"=>"á?&#x2DC;","á?&#x192;"=>"á?&#x152;","ឞ"=>"Î&#x2122;","áž?"=>"áž?","áž?"=>"រ","ឰ"=>"ី","ឧ"=>"áž?","áž?"=>"ណ","áž?"=>"ឭ","ឤ"=>"áž?",
  823. "áž?"=>"áž?","áž?"=>"áž?","áž?"=>"ដ","áž&#x2014;"=>"áž&#x;","áž&#x2013;"=>"áž&#x17E;","áž&#x2022;"=>"áž?","áž&#x201D;"=>"áž&#x153;","áž&#x201C;"=>"áž&#x203A;","áž&#x2019;"=>"áž&#x161;","áž&#x2018;"=>"áž&#x2122;",
  824. "áž?"=>"áž&#x2DC;","áž&#x2021;"=>"áž?","áž&#x2020;"=>"áž&#x17D;","áž&#x2026;"=>"áž?","áž&#x201E;"=>"áž&#x152;","áž&#x192;"=>"áž&#x2039;","áž&#x201A;"=>"áž&#x160;","ហ"=>"áž&#x2030;","áž&#x20AC;"=>"áž&#x2C6;","á??"=>"á??",
  825. "á??"=>"á??","á??"=>"á??","á??"=>"á??","á?š"=>"á?š","á?¸"=>"á?¸","á??"=>"á?&#x203A;","á??"=>"á?&#x161;","á??"=>"á?&#x2039;","á?´"=>"á?&#x160;","á??"=>"á?&#x2030;",
  826. "á??"=>"á?&#x2C6;","á??"=>"áž?","á?°"=>"áž?","á?§"=>"á??","á??"=>"á?Ž","á??"=>"á?­","á?¤"=>"á??","á??"=>"á??","á??"=>"á??","á??"=>"á?Š",
  827. "á?&#x2014;"=>"á?&#x;","á?&#x2022;"=>"á??","á?&#x201C;"=>"á?&#x203A;","á?&#x2018;"=>"á?&#x2122;","á?&#x2026;"=>"á??","á?&#x201E;"=>"á?&#x152;","á?&#x192;"=>"á?&#x2039;","á?&#x201A;"=>"á?&#x160;","á? "=>"á?&#x2030;","á?&#x20AC;"=>"á?&#x2C6;",
  828. "á??"=>"á??","á??"=>"á?ž","á??"=>"á??","á?´"=>"á??","á??"=>"á??","á??"=>"á??","á??"=>"á?š","á?°"=>"á?¸","á?§"=>"á??","á??"=>"á?Ž",
  829. "á??"=>"á?­","á?¤"=>"á??","á??"=>"á??","á??"=>"á??","á??"=>"á?Š","á?&#x2022;"=>"á??","á?&#x201D;"=>"á?&#x153;","á?&#x201C;"=>"á?&#x203A;","á?&#x2019;"=>"á?&#x161;","á?&#x2018;"=>"á?&#x2122;",
  830. "á??"=>"á?&#x2DC;","á?&#x2021;"=>"á??","á?&#x2020;"=>"á?&#x17D;","á?&#x2026;"=>"á??","á?&#x201E;"=>"á?&#x152;","á?&#x192;"=>"á?&#x2039;","á?&#x201A;"=>"á?&#x160;","á? "=>"á?&#x2030;","á?&#x20AC;"=>"á?&#x2C6;","á?š"=>"á?¸",
  831. "á??"=>"á??","á??"=>"á?´","á??"=>"á??","á??"=>"á?°","á??"=>"á?Ž","á?­"=>"á??","á??"=>"á??","á?Š"=>"á?¨","á?§"=>"á??","á??"=>"á?¤",
  832. "á??"=>"á??","á??"=>"á? ","á?&#x;"=>"á?&#x17E;","á??"=>"á?&#x153;","á?&#x203A;"=>"á?&#x161;","á?&#x2122;"=>"á?&#x2DC;","á?&#x2014;"=>"á?&#x2013;","á?&#x2022;"=>"á?&#x201D;","á?&#x201C;"=>"á?&#x2019;","á?&#x2018;"=>"á??",
  833. "á??"=>"á?&#x17D;","á??"=>"á?&#x152;","á?&#x2039;"=>"á?&#x160;","á?&#x2030;"=>"á?&#x2C6;","á?&#x2021;"=>"á?&#x2020;","á?&#x2026;"=>"á?&#x201E;","á?&#x192;"=>"á?&#x201A;","á? "=>"á?&#x20AC;","á??"=>"á?ž","á??"=>"á??",
  834. "á??"=>"á??","á?š"=>"á?¸","á??"=>"á??","á??"=>"á?´","á??"=>"á??","á??"=>"á?°","á??"=>"á?Ž","á?­"=>"á??","á??"=>"á??","á?Š"=>"á?¨",
  835. "á?§"=>"á??","á??"=>"á?¤","á??"=>"á??","á??"=>"á? ","á?&#x203A;"=>"ᚠ","á?&#x2022;"=>"á?&#x201D;","á?&#x201C;"=>"á?&#x2019;","á?&#x2018;"=>"á??","á??"=>"á?&#x17D;","á??"=>"á?&#x152;",
  836. "á?&#x2039;"=>"á?&#x160;","á?&#x2030;"=>"á?&#x2C6;","á?&#x2021;"=>"á?&#x2020;","á?&#x2026;"=>"á?&#x201E;","á?&#x192;"=>"á?&#x201A;","á? "=>"á?&#x20AC;","áš?"=>"᚞","áš?"=>"áš?","áš?"=>"áš?","ᚚ"=>"ᚸ",
  837. "áš?"=>"áš?","áš?"=>"ᚴ","áš?"=>"áš?","áš?"=>"ᚰ","áš?"=>"ᚎ","ᚭ"=>"áš?","áš?"=>"áš?","ᚊ"=>"ᚨ","ᚧ"=>"áš?","áš?"=>"ᚤ",
  838. "áš?"=>"áš?","áš?"=>"ᚠ","áš&#x;"=>"áš&#x17E;","áš?"=>"áš&#x153;","áš&#x203A;"=>"áš&#x161;","áš&#x2122;"=>"áš&#x2DC;","áš&#x2014;"=>"áš&#x2013;","áš&#x2022;"=>"áš&#x201D;","áš&#x201C;"=>"áš&#x2019;","áš&#x2018;"=>"áš?",
  839. "áš?"=>"áš&#x17D;","áš?"=>"áš&#x152;","áš&#x2039;"=>"áš&#x160;","áš&#x2030;"=>"áš&#x2C6;","áš&#x2021;"=>"áš&#x2020;","áš&#x2026;"=>"áš&#x201E;","áš&#x192;"=>"áš&#x201A;","ᚠ"=>"áš&#x20AC;","á¸?"=>"Ḟ","á¸?"=>"á¸?",
  840. "á¸?"=>"á¸?","Ḛ"=>"Ḹ","á¸?"=>"á¸?","á¸?"=>"Ḵ","á¸?"=>"á¸?","á¸?"=>"Ḱ","á¸?"=>"Ḏ","ḭ"=>"á¸?","á¸?"=>"á¸?","Ḋ"=>"Ḩ",
  841. "ḧ"=>"á¸?","á¸?"=>"Ḥ","á¸?"=>"á¸?","á¸?"=>"Ḡ","á¸&#x;"=>"á¸&#x17E;","á¸?"=>"á¸&#x153;","á¸&#x203A;"=>"á¸&#x161;","á¸&#x2122;"=>"á¸&#x2DC;","á¸&#x2014;"=>"á¸&#x2013;","á¸&#x2022;"=>"á¸&#x201D;",
  842. "á¸&#x201C;"=>"á¸&#x2019;","á¸&#x2018;"=>"á¸?","á¸?"=>"á¸&#x17D;","á¸?"=>"á¸&#x152;","á¸&#x2039;"=>"á¸&#x160;","á¸&#x2030;"=>"á¸&#x2C6;","á¸&#x2021;"=>"á¸&#x2020;","á¸&#x2026;"=>"á¸&#x201E;","á¸&#x192;"=>"á¸&#x201A;","Ḡ"=>"á¸&#x20AC;",
  843. "Ö&#x2020;"=>"?&#x2013;","Ö&#x2026;"=>"?&#x2022;","Ö&#x201E;"=>"?&#x201D;","Ö&#x192;"=>"?&#x201C;","Ö&#x201A;"=>"?&#x2019;","Ö "=>"?&#x2018;","Ö&#x20AC;"=>"??","??"=>"??","?ž"=>"?&#x17D;","??"=>"??",
  844. "??"=>"?&#x152;","??"=>"?&#x2039;","??"=>"?&#x160;","?š"=>"?&#x2030;","?¸"=>"?&#x2C6;","??"=>"?&#x2021;","??"=>"?&#x2020;","??"=>"?&#x2026;","?´"=>"?&#x201E;","??"=>"?&#x192;",
  845. "??"=>"?&#x201A;","??"=>"? ","?°"=>"?&#x20AC;","??"=>"Ô?","?Ž"=>"Ԟ","?­"=>"Ô?","??"=>"Ô?","??"=>"Ô?","??"=>"Ô?","?Š"=>"Ԛ",
  846. "?¨"=>"Ô¸","?§"=>"Ô?","??"=>"Ô?","??"=>"Ô?","?¤"=>"Ô´","??"=>"Ô?","??"=>"Ô?","??"=>"Ô?","Ô?"=>"Ô&#x17D;","Ô?"=>"Ô&#x152;",
  847. "Ô&#x2039;"=>"Ô&#x160;","Ô&#x2030;"=>"Ô&#x2C6;","Ô&#x2021;"=>"Ô&#x2020;","Ô&#x2026;"=>"Ô&#x201E;","Ô&#x192;"=>"Ô&#x201A;","Ô "=>"Ô&#x20AC;","Ӛ"=>"Ó¸","Ó?"=>"Ó´","Ó?"=>"Ó?","Ó?"=>"Ó°",
  848. "Ó?"=>"ӎ","Ó­"=>"Ó?","Ó?"=>"Ó?","ӊ"=>"Ó¨","Ó§"=>"Ó?","Ó?"=>"Ó¤","Ó?"=>"Ó?","Ó?"=>"Ó ","Ó&#x;"=>"Ó&#x17E;","Ó?"=>"Ó&#x153;",
  849. "Ó&#x203A;"=>"Ó&#x161;","Ó&#x2122;"=>"Ó&#x2DC;","Ó&#x2014;"=>"Ó&#x2013;","Ó&#x2022;"=>"Ó&#x201D;","Ó&#x201C;"=>"Ó&#x2019;","Ó&#x2018;"=>"Ó?","Ó&#x17D;"=>"Ó?","Ó&#x152;"=>"Ó&#x2039;","Ó&#x160;"=>"Ó&#x2030;","Ó&#x2C6;"=>"Ó&#x2021;",
  850. "Ó&#x2020;"=>"Ó&#x2026;","Ó&#x201E;"=>"Ó&#x192;","Ó&#x201A;"=>"Ó ","??"=>"?ž","??"=>"??","??"=>"??","?š"=>"?¸","??"=>"??","??"=>"?´","??"=>"??",
  851. "??"=>"?°","??"=>"?Ž","?­"=>"??","??"=>"??","?Š"=>"?¨","?§"=>"??","??"=>"?¤","??"=>"??","??"=>"? ","?&#x;"=>"?&#x17E;",
  852. "??"=>"?&#x153;","?&#x203A;"=>"?&#x161;","?&#x2122;"=>"?&#x2DC;","?&#x2014;"=>"?&#x2013;","?&#x2022;"=>"?&#x201D;","?&#x201C;"=>"?&#x2019;","?&#x2018;"=>"??","??"=>"?&#x17D;","??"=>"?&#x152;","?&#x2039;"=>"?&#x160;",
  853. "? "=>"?&#x20AC;","??"=>"?ž","??"=>"??","??"=>"??","?š"=>"?¸","??"=>"??","??"=>"?´","??"=>"??","??"=>"?°","??"=>"?Ž",
  854. "?­"=>"??","??"=>"??","?Š"=>"?¨","?§"=>"??","??"=>"?¤","??"=>"??","??"=>"? ","?&#x;"=>"??","?&#x17E;"=>"?&#x17D;","??"=>"??",
  855. "?&#x153;"=>"?&#x152;","?&#x203A;"=>"?&#x2039;","?&#x161;"=>"?&#x160;","?&#x2122;"=>"?&#x2030;","?&#x2DC;"=>"?&#x2C6;","?&#x2014;"=>"?&#x2021;","?&#x2013;"=>"?&#x2020;","?&#x2022;"=>"?&#x2026;","?&#x201D;"=>"?&#x201E;","?&#x201C;"=>"?&#x192;",
  856. "?&#x2019;"=>"?&#x201A;","?&#x2018;"=>"? ","??"=>"?&#x20AC;","??"=>"??","?&#x17D;"=>"?Ž","??"=>"?­","?&#x152;"=>"??","?&#x2039;"=>"??","?&#x160;"=>"??","?&#x2030;"=>"?Š",
  857. "?&#x2C6;"=>"?¨","?&#x2021;"=>"?§","?&#x2020;"=>"??","?&#x2026;"=>"??","?&#x201E;"=>"?¤","?&#x192;"=>"??","?&#x201A;"=>"??","? "=>"??","?&#x20AC;"=>"? ","??"=>"?&#x;",
  858. "?ž"=>"?&#x17E;","??"=>"??","??"=>"?&#x153;","??"=>"?&#x203A;","??"=>"?&#x161;","?š"=>"?&#x2122;","?¸"=>"?&#x2DC;","??"=>"?&#x2014;","??"=>"?&#x2013;","??"=>"?&#x2022;",
  859. "?´"=>"?&#x201D;","??"=>"?&#x201C;","??"=>"?&#x2019;","??"=>"?&#x2018;","?°"=>"??","??"=>"Î&#x2022;","??"=>"Î?","??"=>"Î?","?°"=>"Î&#x161;","??"=>"?Ž",
  860. "?­"=>"??","??"=>"??","?Š"=>"?¨","?§"=>"??","??"=>"?¤","??"=>"??","??"=>"? ","?&#x;"=>"?&#x17E;","??"=>"?&#x153;","?&#x203A;"=>"?&#x161;",
  861. "?&#x2122;"=>"?&#x2DC;","?&#x2013;"=>"Π","?&#x2022;"=>"Î?","?&#x2018;"=>"Î&#x2DC;","??"=>"Î&#x2019;","?&#x17D;"=>"Î?","??"=>"Î&#x17D;","?&#x152;"=>"Î&#x152;","?&#x2039;"=>"Î?","?&#x160;"=>"Î?",
  862. "?&#x2030;"=>"Ί","?&#x2C6;"=>"Ψ","?&#x2021;"=>"Χ","?&#x2020;"=>"Î?","?&#x2026;"=>"Î?","?&#x201E;"=>"Τ","?&#x192;"=>"Î?","?&#x201A;"=>"Î?","? "=>"Î?","?&#x20AC;"=>"Π",
  863. "Î?"=>"Î&#x;","Ξ"=>"Î&#x17E;","Î?"=>"Î?","Î?"=>"Î&#x153;","Î?"=>"Î&#x203A;","Î?"=>"Î&#x161;","Κ"=>"Î&#x2122;","θ"=>"Î&#x2DC;","Î?"=>"Î&#x2014;","Î?"=>"Î&#x2013;",
  864. "Î?"=>"Î&#x2022;","δ"=>"Î&#x201D;","Î?"=>"Î&#x201C;","Î?"=>"Î&#x2019;","Î?"=>"Î&#x2018;","Î?"=>"Î&#x160;","Ύ"=>"Î&#x2030;","έ"=>"Î&#x2C6;","Î?"=>"Î&#x2020;","?&#x2019;"=>"??",
  865. "?&#x2039;"=>"??","?&#x160;"=>"??","?&#x2C6;"=>"?Ž","?&#x192;"=>"?Š","?&#x20AC;"=>"??","É?"=>"?&#x;","É?"=>"??","É?"=>"?&#x153;","Ɋ"=>"?&#x2013;","ɨ"=>"?&#x2014;",
  866. "É?"=>"?&#x201D;","É&#x203A;"=>"??","É&#x2122;"=>"??","É&#x2014;"=>"?&#x160;","É&#x2013;"=>"?&#x2030;","É&#x201D;"=>"?&#x2020;","É&#x201C;"=>"? ","??"=>"??","??"=>"?°","??"=>"?Ž",
  867. "?­"=>"??","??"=>"??","?Š"=>"?¨","?§"=>"??","??"=>"?¤","??"=>"??","?&#x;"=>"?&#x17E;","??"=>"?&#x153;","?&#x203A;"=>"?&#x161;","?&#x2122;"=>"?&#x2DC;",
  868. "?&#x2014;"=>"?&#x2013;","?&#x2022;"=>"?&#x201D;","?&#x201C;"=>"?&#x2019;","?&#x2018;"=>"??","??"=>"?&#x17D;","??"=>"?&#x152;","?&#x2039;"=>"?&#x160;","?&#x2030;"=>"?&#x2C6;","?&#x2021;"=>"?&#x2020;","?&#x2026;"=>"?&#x201E;",
  869. "?&#x192;"=>"?&#x201A;","? "=>"?&#x20AC;","Ç?"=>"Ǟ","Ç?"=>"Ç?","Ç?"=>"Ç?","ǚ"=>"Ǹ","Ç?"=>"Ç´","Ç?"=>"Ç?","Ç?"=>"ǎ","Ç­"=>"Ç?",
  870. "Ç?"=>"Ç?","NJ"=>"Ǩ","ǧ"=>"Ç?","Ç?"=>"Ǥ","Ç?"=>"Ç?","Ç?"=>"Ç ","Ç&#x;"=>"Ç&#x17E;","Ç?"=>"?&#x17D;","Ç&#x153;"=>"Ç&#x203A;","Ç&#x161;"=>"Ç&#x2122;",
  871. "Ç&#x2DC;"=>"Ç&#x2014;","Ç&#x2013;"=>"Ç&#x2022;","Ç&#x201D;"=>"Ç&#x201C;","Ç&#x2019;"=>"Ç&#x2018;","Ç?"=>"Ç?","Ç&#x17D;"=>"Ç?","Ç&#x152;"=>"Ç&#x2039;","Ç&#x2030;"=>"Ç&#x2C6;","Ç&#x2020;"=>"Ç&#x2026;","??"=>"Ç?",
  872. "??"=>"??","?š"=>"?¸","??"=>"??","?´"=>"??","?°"=>"??","?­"=>"??","?¨"=>"?§","??"=>"?¤","??"=>"??","??"=>"? ",
  873. "?&#x17E;"=>"? ","?&#x2122;"=>"?&#x2DC;","?&#x2022;"=>"Ç?","?&#x2019;"=>"?&#x2018;","?&#x152;"=>"?&#x2039;","?&#x2C6;"=>"?&#x2021;","?&#x2026;"=>"?&#x201E;","?&#x192;"=>"?&#x201A;","??"=>"S","?ž"=>"??",
  874. "??"=>"??","??"=>"?š","??"=>"??","??"=>"?´","??"=>"??","??"=>"?°","??"=>"?Ž","?­"=>"??","??"=>"??","?Š"=>"?¨",
  875. "?§"=>"??","??"=>"?¤","??"=>"??","??"=>"? ","?&#x;"=>"?&#x17E;","??"=>"?&#x153;","?&#x203A;"=>"?&#x161;","?&#x2122;"=>"?&#x2DC;","?&#x2014;"=>"?&#x2013;","?&#x2022;"=>"?&#x201D;",
  876. "?&#x201C;"=>"?&#x2019;","?&#x2018;"=>"??","??"=>"?&#x17D;","??"=>"?&#x152;","?&#x2039;"=>"?&#x160;","?&#x2C6;"=>"?&#x2021;","?&#x2020;"=>"?&#x2026;","?&#x201E;"=>"?&#x192;","?&#x201A;"=>"? ","?&#x20AC;"=>"Ä?",
  877. "Ğ"=>"Ä?","Ä?"=>"Ä?","Ä?"=>"Ě","Ä?"=>"Ä?","Ä?"=>"Ä´","Ä?"=>"Ä?","Ä?"=>"I","Ä?"=>"Ď","Ä­"=>"Ä?","Ä?"=>"Ä?",
  878. "Ċ"=>"Ĩ","ħ"=>"Ä?","Ä?"=>"Ĥ","Ä?"=>"Ä?","Ä?"=>"Ä ","Ä&#x;"=>"Ä&#x17E;","Ä?"=>"Ä&#x153;","Ä&#x203A;"=>"Ä&#x161;","Ä&#x2122;"=>"Ä&#x2DC;","Ä&#x2014;"=>"Ä&#x2013;",
  879. "Ä&#x2022;"=>"Ä&#x201D;","Ä&#x201C;"=>"Ä&#x2019;","Ä&#x2018;"=>"Ä?","Ä?"=>"Ä&#x17D;","Ä?"=>"Ä&#x152;","Ä&#x2039;"=>"Ä&#x160;","Ä&#x2030;"=>"Ä&#x2C6;","Ä&#x2021;"=>"Ä&#x2020;","Ä&#x2026;"=>"Ä&#x201E;","Ä&#x192;"=>"Ä&#x201A;",
  880. "Ä "=>"Ä&#x20AC;","??"=>"?¸","?ž"=>"?&#x17E;","??"=>"??","??"=>"?&#x153;","??"=>"?&#x203A;","??"=>"?&#x161;","?š"=>"?&#x2122;","?¸"=>"?&#x2DC;","??"=>"?&#x2013;",
  881. "??"=>"?&#x2022;","?´"=>"?&#x201D;","??"=>"?&#x201C;","??"=>"?&#x2019;","??"=>"?&#x2018;","?°"=>"??","??"=>"??","?Ž"=>"?&#x17D;","?­"=>"??","??"=>"?&#x152;",
  882. "??"=>"?&#x2039;","??"=>"?&#x160;","?Š"=>"?&#x2030;","?¨"=>"?&#x2C6;","?§"=>"?&#x2021;","??"=>"?&#x2020;","??"=>"?&#x2026;","?¤"=>"?&#x201E;","??"=>"?&#x192;","??"=>"?&#x201A;",
  883. "??"=>"? ","? "=>"?&#x20AC;","Â?"=>"Î&#x153;","z"=>"Z","y"=>"Y","x"=>"X","w"=>"W","v"=>"V","u"=>"U","t"=>"T",
  884. "s"=>"S","r"=>"R","q"=>"Q","p"=>"P","o"=>"O","n"=>"N","m"=>"M","l"=>"L","k"=>"K","j"=>"J",
  885. "i"=>"I","h"=>"H","g"=>"G","f"=>"F","e"=>"E","d"=>"D","c"=>"C","b"=>"B","a"=>"A"
  886. );
  887. /**
  888. * UTF-8 Case lookup table
  889. *
  890. * This lookuptable defines the lower case letters to their correspponding
  891. * upper case letter in UTF-8
  892. *
  893. * @author Andreas Gohr <andi@splitbrain.org>
  894. */
  895. global $UTF8_UPPER_TO_LOWER;
  896. if(empty($UTF8_UPPER_TO_LOWER)) $UTF8_UPPER_TO_LOWER = array (
  897. "???"=>"??&#x161;","??š"=>"??&#x2122;","??¸"=>"??&#x2DC;","???"=>"??&#x2014;","???"=>"??&#x2013;","???"=>"??&#x2022;","??´"=>"??&#x201D;","???"=>"??&#x201C;","???"=>"??&#x2019;","???"=>"??&#x2018;",
  898. "??°"=>"???","???"=>"???","??Ž"=>"??&#x17D;","??­"=>"???","???"=>"??&#x152;","???"=>"??&#x2039;","???"=>"??&#x160;","??Š"=>"??&#x2030;","??¨"=>"??&#x2C6;","??§"=>"??&#x2021;",
  899. "???"=>"??&#x2020;","???"=>"??&#x2026;","??¤"=>"??&#x201E;","???"=>"??&#x192;","???"=>"??&#x201A;","???"=>"?? ","á??"=>"á??","á??"=>"á??","á?Š"=>"á??","á?&#x2122;"=>"á?&#x2018;",
  900. "á?&#x2DC;"=>"á??","á?&#x152;"=>"á?&#x192;","Î&#x2122;"=>"ឞ","áž?"=>"áž?","រ"=>"áž?","ី"=>"ឰ","áž?"=>"ឧ","ណ"=>"áž?","ឭ"=>"áž?","áž?"=>"ឤ",
  901. "áž?"=>"áž?","áž?"=>"áž?","ដ"=>"áž?","áž&#x;"=>"áž&#x2014;","áž&#x17E;"=>"áž&#x2013;","áž?"=>"áž&#x2022;","áž&#x153;"=>"áž&#x201D;","áž&#x203A;"=>"áž&#x201C;","áž&#x161;"=>"áž&#x2019;","áž&#x2122;"=>"áž&#x2018;",
  902. "áž&#x2DC;"=>"áž?","áž?"=>"áž&#x2021;","áž&#x17D;"=>"áž&#x2020;","áž?"=>"áž&#x2026;","áž&#x152;"=>"áž&#x201E;","áž&#x2039;"=>"áž&#x192;","áž&#x160;"=>"áž&#x201A;","áž&#x2030;"=>"ហ","áž&#x2C6;"=>"áž&#x20AC;","á??"=>"á??",
  903. "á??"=>"á??","á??"=>"á??","á??"=>"á??","á?š"=>"á?š","á?¸"=>"á?¸","á?&#x203A;"=>"á??","á?&#x161;"=>"á??","á?&#x2039;"=>"á??","á?&#x160;"=>"á?´","á?&#x2030;"=>"á??",
  904. "á?&#x2C6;"=>"á??","áž?"=>"á??","áž?"=>"á?°","á??"=>"á?§","á?Ž"=>"á??","á?­"=>"á??","á??"=>"á?¤","á??"=>"á??","á??"=>"á??","á?Š"=>"á??",
  905. "á?&#x;"=>"á?&#x2014;","á??"=>"á?&#x2022;","á?&#x203A;"=>"á?&#x201C;","á?&#x2122;"=>"á?&#x2018;","á??"=>"á?&#x2026;","á?&#x152;"=>"á?&#x201E;","á?&#x2039;"=>"á?&#x192;","á?&#x160;"=>"á?&#x201A;","á?&#x2030;"=>"á? ","á?&#x2C6;"=>"á?&#x20AC;",
  906. "á??"=>"á??","á?ž"=>"á??","á??"=>"á??","á??"=>"á?´","á??"=>"á??","á??"=>"á??","á?š"=>"á??","á?¸"=>"á?°","á??"=>"á?§","á?Ž"=>"á??",
  907. "á?­"=>"á??","á??"=>"á?¤","á??"=>"á??","á??"=>"á??","á?Š"=>"á??","á??"=>"á?&#x2022;","á?&#x153;"=>"á?&#x201D;","á?&#x203A;"=>"á?&#x201C;","á?&#x161;"=>"á?&#x2019;","á?&#x2122;"=>"á?&#x2018;",
  908. "á?&#x2DC;"=>"á??","á??"=>"á?&#x2021;","á?&#x17D;"=>"á?&#x2020;","á??"=>"á?&#x2026;","á?&#x152;"=>"á?&#x201E;","á?&#x2039;"=>"á?&#x192;","á?&#x160;"=>"á?&#x201A;","á?&#x2030;"=>"á? ","á?&#x2C6;"=>"á?&#x20AC;","á?¸"=>"á?š",
  909. "á??"=>"á??","á?´"=>"á??","á??"=>"á??","á?°"=>"á??","á?Ž"=>"á??","á??"=>"á?­","á??"=>"á??","á?¨"=>"á?Š","á??"=>"á?§","á?¤"=>"á??",
  910. "á??"=>"á??","á? "=>"á??","á?&#x17E;"=>"á?&#x;","á?&#x153;"=>"á??","á?&#x161;"=>"á?&#x203A;","á?&#x2DC;"=>"á?&#x2122;","á?&#x2013;"=>"á?&#x2014;","á?&#x201D;"=>"á?&#x2022;","á?&#x2019;"=>"á?&#x201C;","á??"=>"á?&#x2018;",
  911. "á?&#x17D;"=>"á??","á?&#x152;"=>"á??","á?&#x160;"=>"á?&#x2039;","á?&#x2C6;"=>"á?&#x2030;","á?&#x2020;"=>"á?&#x2021;","á?&#x201E;"=>"á?&#x2026;","á?&#x201A;"=>"á?&#x192;","á?&#x20AC;"=>"á? ","á?ž"=>"á??","á??"=>"á??",
  912. "á??"=>"á??","á?¸"=>"á?š","á??"=>"á??","á?´"=>"á??","á??"=>"á??","á?°"=>"á??","á?Ž"=>"á??","á??"=>"á?­","á??"=>"á??","á?¨"=>"á?Š",
  913. "á??"=>"á?§","á?¤"=>"á??","á??"=>"á??","á? "=>"á??","ᚠ"=>"á?&#x203A;","á?&#x201D;"=>"á?&#x2022;","á?&#x2019;"=>"á?&#x201C;","á??"=>"á?&#x2018;","á?&#x17D;"=>"á??","á?&#x152;"=>"á??",
  914. "á?&#x160;"=>"á?&#x2039;","á?&#x2C6;"=>"á?&#x2030;","á?&#x2020;"=>"á?&#x2021;","á?&#x201E;"=>"á?&#x2026;","á?&#x201A;"=>"á?&#x192;","á?&#x20AC;"=>"á? ","᚞"=>"áš?","áš?"=>"áš?","áš?"=>"áš?","ᚸ"=>"ᚚ",
  915. "áš?"=>"áš?","ᚴ"=>"áš?","áš?"=>"áš?","ᚰ"=>"áš?","ᚎ"=>"áš?","áš?"=>"ᚭ","áš?"=>"áš?","ᚨ"=>"ᚊ","áš?"=>"ᚧ","ᚤ"=>"áš?",
  916. "áš?"=>"áš?","ᚠ"=>"áš?","áš&#x17E;"=>"áš&#x;","áš&#x153;"=>"áš?","áš&#x161;"=>"áš&#x203A;","áš&#x2DC;"=>"áš&#x2122;","áš&#x2013;"=>"áš&#x2014;","áš&#x201D;"=>"áš&#x2022;","áš&#x2019;"=>"áš&#x201C;","áš?"=>"áš&#x2018;",
  917. "áš&#x17D;"=>"áš?","áš&#x152;"=>"áš?","áš&#x160;"=>"áš&#x2039;","áš&#x2C6;"=>"áš&#x2030;","áš&#x2020;"=>"áš&#x2021;","áš&#x201E;"=>"áš&#x2026;","áš&#x201A;"=>"áš&#x192;","áš&#x20AC;"=>"ᚠ","Ḟ"=>"á¸?","á¸?"=>"á¸?",
  918. "á¸?"=>"á¸?","Ḹ"=>"Ḛ","á¸?"=>"á¸?","Ḵ"=>"á¸?","á¸?"=>"á¸?","Ḱ"=>"á¸?","Ḏ"=>"á¸?","á¸?"=>"ḭ","á¸?"=>"á¸?","Ḩ"=>"Ḋ",
  919. "á¸?"=>"ḧ","Ḥ"=>"á¸?","á¸?"=>"á¸?","Ḡ"=>"á¸?","á¸&#x17E;"=>"á¸&#x;","á¸&#x153;"=>"á¸?","á¸&#x161;"=>"á¸&#x203A;","á¸&#x2DC;"=>"á¸&#x2122;","á¸&#x2013;"=>"á¸&#x2014;","á¸&#x201D;"=>"á¸&#x2022;",
  920. "á¸&#x2019;"=>"á¸&#x201C;","á¸?"=>"á¸&#x2018;","á¸&#x17D;"=>"á¸?","á¸&#x152;"=>"á¸?","á¸&#x160;"=>"á¸&#x2039;","á¸&#x2C6;"=>"á¸&#x2030;","á¸&#x2020;"=>"á¸&#x2021;","á¸&#x201E;"=>"á¸&#x2026;","á¸&#x201A;"=>"á¸&#x192;","á¸&#x20AC;"=>"Ḡ",
  921. "?&#x2013;"=>"Ö&#x2020;","?&#x2022;"=>"Ö&#x2026;","?&#x201D;"=>"Ö&#x201E;","?&#x201C;"=>"Ö&#x192;","?&#x2019;"=>"Ö&#x201A;","?&#x2018;"=>"Ö ","??"=>"Ö&#x20AC;","??"=>"??","?&#x17D;"=>"?ž","??"=>"??",
  922. "?&#x152;"=>"??","?&#x2039;"=>"??","?&#x160;"=>"??","?&#x2030;"=>"?š","?&#x2C6;"=>"?¸","?&#x2021;"=>"??","?&#x2020;"=>"??","?&#x2026;"=>"??","?&#x201E;"=>"?´","?&#x192;"=>"??",
  923. "?&#x201A;"=>"??","? "=>"??","?&#x20AC;"=>"?°","Ô?"=>"??","Ԟ"=>"?Ž","Ô?"=>"?­","Ô?"=>"??","Ô?"=>"??","Ô?"=>"??","Ԛ"=>"?Š",
  924. "Ô¸"=>"?¨","Ô?"=>"?§","Ô?"=>"??","Ô?"=>"??","Ô´"=>"?¤","Ô?"=>"??","Ô?"=>"??","Ô?"=>"??","Ô&#x17D;"=>"Ô?","Ô&#x152;"=>"Ô?",
  925. "Ô&#x160;"=>"Ô&#x2039;","Ô&#x2C6;"=>"Ô&#x2030;","Ô&#x2020;"=>"Ô&#x2021;","Ô&#x201E;"=>"Ô&#x2026;","Ô&#x201A;"=>"Ô&#x192;","Ô&#x20AC;"=>"Ô ","Ó¸"=>"Ӛ","Ó´"=>"Ó?","Ó?"=>"Ó?","Ó°"=>"Ó?",
  926. "ӎ"=>"Ó?","Ó?"=>"Ó­","Ó?"=>"Ó?","Ó¨"=>"ӊ","Ó?"=>"Ó§","Ó¤"=>"Ó?","Ó?"=>"Ó?","Ó "=>"Ó?","Ó&#x17E;"=>"Ó&#x;","Ó&#x153;"=>"Ó?",
  927. "Ó&#x161;"=>"Ó&#x203A;","Ó&#x2DC;"=>"Ó&#x2122;","Ó&#x2013;"=>"Ó&#x2014;","Ó&#x201D;"=>"Ó&#x2022;","Ó&#x2019;"=>"Ó&#x201C;","Ó?"=>"Ó&#x2018;","Ó?"=>"Ó&#x17D;","Ó&#x2039;"=>"Ó&#x152;","Ó&#x2030;"=>"Ó&#x160;","Ó&#x2021;"=>"Ó&#x2C6;",
  928. "Ó&#x2026;"=>"Ó&#x2020;","Ó&#x192;"=>"Ó&#x201E;","Ó "=>"Ó&#x201A;","?ž"=>"??","??"=>"??","??"=>"??","?¸"=>"?š","??"=>"??","?´"=>"??","??"=>"??",
  929. "?°"=>"??","?Ž"=>"??","??"=>"?­","??"=>"??","?¨"=>"?Š","??"=>"?§","?¤"=>"??","??"=>"??","? "=>"??","?&#x17E;"=>"?&#x;",
  930. "?&#x153;"=>"??","?&#x161;"=>"?&#x203A;","?&#x2DC;"=>"?&#x2122;","?&#x2013;"=>"?&#x2014;","?&#x201D;"=>"?&#x2022;","?&#x2019;"=>"?&#x201C;","??"=>"?&#x2018;","?&#x17D;"=>"??","?&#x152;"=>"??","?&#x160;"=>"?&#x2039;",
  931. "?&#x20AC;"=>"? ","?ž"=>"??","??"=>"??","??"=>"??","?¸"=>"?š","??"=>"??","?´"=>"??","??"=>"??","?°"=>"??","?Ž"=>"??",
  932. "??"=>"?­","??"=>"??","?¨"=>"?Š","??"=>"?§","?¤"=>"??","??"=>"??","? "=>"??","??"=>"?&#x;","?&#x17D;"=>"?&#x17E;","??"=>"??",
  933. "?&#x152;"=>"?&#x153;","?&#x2039;"=>"?&#x203A;","?&#x160;"=>"?&#x161;","?&#x2030;"=>"?&#x2122;","?&#x2C6;"=>"?&#x2DC;","?&#x2021;"=>"?&#x2014;","?&#x2020;"=>"?&#x2013;","?&#x2026;"=>"?&#x2022;","?&#x201E;"=>"?&#x201D;","?&#x192;"=>"?&#x201C;",
  934. "?&#x201A;"=>"?&#x2019;","? "=>"?&#x2018;","?&#x20AC;"=>"??","??"=>"??","?Ž"=>"?&#x17D;","?­"=>"??","??"=>"?&#x152;","??"=>"?&#x2039;","??"=>"?&#x160;","?Š"=>"?&#x2030;",
  935. "?¨"=>"?&#x2C6;","?§"=>"?&#x2021;","??"=>"?&#x2020;","??"=>"?&#x2026;","?¤"=>"?&#x201E;","??"=>"?&#x192;","??"=>"?&#x201A;","??"=>"? ","? "=>"?&#x20AC;","?&#x;"=>"??",
  936. "?&#x17E;"=>"?ž","??"=>"??","?&#x153;"=>"??","?&#x203A;"=>"??","?&#x161;"=>"??","?&#x2122;"=>"?š","?&#x2DC;"=>"?¸","?&#x2014;"=>"??","?&#x2013;"=>"??","?&#x2022;"=>"??",
  937. "?&#x201D;"=>"?´","?&#x201C;"=>"??","?&#x2019;"=>"??","?&#x2018;"=>"??","??"=>"?°","Î&#x2022;"=>"??","Î?"=>"??","Î?"=>"??","Î&#x161;"=>"?°","?Ž"=>"??",
  938. "??"=>"?­","??"=>"??","?¨"=>"?Š","??"=>"?§","?¤"=>"??","??"=>"??","? "=>"??","?&#x17E;"=>"?&#x;","?&#x153;"=>"??","?&#x161;"=>"?&#x203A;",
  939. "?&#x2DC;"=>"?&#x2122;","Π"=>"?&#x2013;","Î?"=>"?&#x2022;","Î&#x2DC;"=>"?&#x2018;","Î&#x2019;"=>"??","Î?"=>"?&#x17D;","Î&#x17D;"=>"??","Î&#x152;"=>"?&#x152;","Î?"=>"?&#x2039;","Î?"=>"?&#x160;",
  940. "Ί"=>"?&#x2030;","Ψ"=>"?&#x2C6;","Χ"=>"?&#x2021;","Î?"=>"?&#x2020;","Î?"=>"?&#x2026;","Τ"=>"?&#x201E;","Î?"=>"?&#x192;","Î?"=>"?&#x201A;","Î?"=>"? ","Π"=>"?&#x20AC;",
  941. "Î&#x;"=>"Î?","Î&#x17E;"=>"Ξ","Î?"=>"Î?","Î&#x153;"=>"Î?","Î&#x203A;"=>"Î?","Î&#x161;"=>"Î?","Î&#x2122;"=>"Κ","Î&#x2DC;"=>"θ","Î&#x2014;"=>"Î?","Î&#x2013;"=>"Î?",
  942. "Î&#x2022;"=>"Î?","Î&#x201D;"=>"δ","Î&#x201C;"=>"Î?","Î&#x2019;"=>"Î?","Î&#x2018;"=>"Î?","Î&#x160;"=>"Î?","Î&#x2030;"=>"Ύ","Î&#x2C6;"=>"έ","Î&#x2020;"=>"Î?","??"=>"?&#x2019;",
  943. "??"=>"?&#x2039;","??"=>"?&#x160;","?Ž"=>"?&#x2C6;","?Š"=>"?&#x192;","??"=>"?&#x20AC;","?&#x;"=>"É?","??"=>"É?","?&#x153;"=>"É?","?&#x2013;"=>"Ɋ","?&#x2014;"=>"ɨ",
  944. "?&#x201D;"=>"É?","??"=>"É&#x203A;","??"=>"É&#x2122;","?&#x160;"=>"É&#x2014;","?&#x2030;"=>"É&#x2013;","?&#x2020;"=>"É&#x201D;","? "=>"É&#x201C;","??"=>"??","?°"=>"??","?Ž"=>"??",
  945. "??"=>"?­","??"=>"??","?¨"=>"?Š","??"=>"?§","?¤"=>"??","??"=>"??","?&#x17E;"=>"?&#x;","?&#x153;"=>"??","?&#x161;"=>"?&#x203A;","?&#x2DC;"=>"?&#x2122;",
  946. "?&#x2013;"=>"?&#x2014;","?&#x201D;"=>"?&#x2022;","?&#x2019;"=>"?&#x201C;","??"=>"?&#x2018;","?&#x17D;"=>"??","?&#x152;"=>"??","?&#x160;"=>"?&#x2039;","?&#x2C6;"=>"?&#x2030;","?&#x2020;"=>"?&#x2021;","?&#x201E;"=>"?&#x2026;",
  947. "?&#x201A;"=>"?&#x192;","?&#x20AC;"=>"? ","Ǟ"=>"Ç?","Ç?"=>"Ç?","Ç?"=>"Ç?","Ǹ"=>"ǚ","Ç´"=>"Ç?","Ç?"=>"Ç?","ǎ"=>"Ç?","Ç?"=>"Ç­",
  948. "Ç?"=>"Ç?","Ǩ"=>"NJ","Ç?"=>"ǧ","Ǥ"=>"Ç?","Ç?"=>"Ç?","Ç "=>"Ç?","Ç&#x17E;"=>"Ç&#x;","?&#x17D;"=>"Ç?","Ç&#x203A;"=>"Ç&#x153;","Ç&#x2122;"=>"Ç&#x161;",
  949. "Ç&#x2014;"=>"Ç&#x2DC;","Ç&#x2022;"=>"Ç&#x2013;","Ç&#x201C;"=>"Ç&#x201D;","Ç&#x2018;"=>"Ç&#x2019;","Ç?"=>"Ç?","Ç?"=>"Ç&#x17D;","Ç&#x2039;"=>"Ç&#x152;","Ç&#x2C6;"=>"Ç&#x2030;","Ç&#x2026;"=>"Ç&#x2020;","Ç?"=>"??",
  950. "??"=>"??","?¸"=>"?š","??"=>"??","??"=>"?´","??"=>"?°","??"=>"?­","?§"=>"?¨","?¤"=>"??","??"=>"??","? "=>"??",
  951. "? "=>"?&#x17E;","?&#x2DC;"=>"?&#x2122;","Ç?"=>"?&#x2022;","?&#x2018;"=>"?&#x2019;","?&#x2039;"=>"?&#x152;","?&#x2021;"=>"?&#x2C6;","?&#x201E;"=>"?&#x2026;","?&#x201A;"=>"?&#x192;","S"=>"??","??"=>"?ž",
  952. "??"=>"??","?š"=>"??","??"=>"??","?´"=>"??","??"=>"??","?°"=>"??","?Ž"=>"??","??"=>"?­","??"=>"??","?¨"=>"?Š",
  953. "??"=>"?§","?¤"=>"??","??"=>"??","? "=>"??","?&#x17E;"=>"?&#x;","?&#x153;"=>"??","?&#x161;"=>"?&#x203A;","?&#x2DC;"=>"?&#x2122;","?&#x2013;"=>"?&#x2014;","?&#x201D;"=>"?&#x2022;",
  954. "?&#x2019;"=>"?&#x201C;","??"=>"?&#x2018;","?&#x17D;"=>"??","?&#x152;"=>"??","?&#x160;"=>"?&#x2039;","?&#x2021;"=>"?&#x2C6;","?&#x2026;"=>"?&#x2020;","?&#x192;"=>"?&#x201E;","? "=>"?&#x201A;","Ä?"=>"?&#x20AC;",
  955. "Ä?"=>"Ğ","Ä?"=>"Ä?","Ě"=>"Ä?","Ä?"=>"Ä?","Ä´"=>"Ä?","Ä?"=>"Ä?","I"=>"Ä?","Ď"=>"Ä?","Ä?"=>"Ä­","Ä?"=>"Ä?",
  956. "Ĩ"=>"Ċ","Ä?"=>"ħ","Ĥ"=>"Ä?","Ä?"=>"Ä?","Ä "=>"Ä?","Ä&#x17E;"=>"Ä&#x;","Ä&#x153;"=>"Ä?","Ä&#x161;"=>"Ä&#x203A;","Ä&#x2DC;"=>"Ä&#x2122;","Ä&#x2013;"=>"Ä&#x2014;",
  957. "Ä&#x201D;"=>"Ä&#x2022;","Ä&#x2019;"=>"Ä&#x201C;","Ä?"=>"Ä&#x2018;","Ä&#x17D;"=>"Ä?","Ä&#x152;"=>"Ä?","Ä&#x160;"=>"Ä&#x2039;","Ä&#x2C6;"=>"Ä&#x2030;","Ä&#x2020;"=>"Ä&#x2021;","Ä&#x201E;"=>"Ä&#x2026;","Ä&#x201A;"=>"Ä&#x192;",
  958. "Ä&#x20AC;"=>"Ä ","?¸"=>"??","?&#x17E;"=>"?ž","??"=>"??","?&#x153;"=>"??","?&#x203A;"=>"??","?&#x161;"=>"??","?&#x2122;"=>"?š","?&#x2DC;"=>"?¸","?&#x2013;"=>"??",
  959. "?&#x2022;"=>"??","?&#x201D;"=>"?´","?&#x201C;"=>"??","?&#x2019;"=>"??","?&#x2018;"=>"??","??"=>"?°","??"=>"??","?&#x17D;"=>"?Ž","??"=>"?­","?&#x152;"=>"??",
  960. "?&#x2039;"=>"??","?&#x160;"=>"??","?&#x2030;"=>"?Š","?&#x2C6;"=>"?¨","?&#x2021;"=>"?§","?&#x2020;"=>"??","?&#x2026;"=>"??","?&#x201E;"=>"?¤","?&#x192;"=>"??","?&#x201A;"=>"??",
  961. "? "=>"??","?&#x20AC;"=>"? ","Î&#x153;"=>"Â?","Z"=>"z","Y"=>"y","X"=>"x","W"=>"w","V"=>"v","U"=>"u","T"=>"t",
  962. "S"=>"s","R"=>"r","Q"=>"q","P"=>"p","O"=>"o","N"=>"n","M"=>"m","L"=>"l","K"=>"k","J"=>"j",
  963. "I"=>"i","H"=>"h","G"=>"g","F"=>"f","E"=>"e","D"=>"d","C"=>"c","B"=>"b","A"=>"a"
  964. );
  965. }; // end of case lookup tables
  966. /**
  967. * UTF-8 lookup table for lower case accented letters
  968. *
  969. * This lookuptable defines replacements for accented characters from the ASCII-7
  970. * range. This are lower case letters only.
  971. *
  972. * @author Andreas Gohr <andi@splitbrain.org>
  973. * @see utf8_deaccent()
  974. */
  975. global $UTF8_LOWER_ACCENTS;
  976. if(empty($UTF8_LOWER_ACCENTS)) $UTF8_LOWER_ACCENTS = array(
  977. '? ' => 'a', '?´' => 'o', 'Ä?' => 'd', 'á¸&#x;' => 'f', '??' => 'e', '??' => 's', '??' => 'o',
  978. '?&#x;' => 'ss', 'Ä&#x192;' => 'a', '?&#x2122;' => 'r', '?&#x203A;' => 't', '?&#x2C6;' => 'n', 'Ä ' => 'a', 'Ä?' => 'k',
  979. '??' => 's', 'á??' => 'y', '?&#x2020;' => 'n', 'Ä?' => 'l', 'ħ' => 'h', 'áš&#x2014;' => 'p', '??' => 'o',
  980. '??' => 'u', 'Ä&#x203A;' => 'e', '?Š' => 'e', '?§' => 'c', 'á? ' => 'w', 'Ä&#x2039;' => 'c', '??' => 'o',
  981. 'áš?' => 's', '?¸' => 'o', 'Ä?' => 'g', '?§' => 't', '?&#x2122;' => 's', 'Ä&#x2014;' => 'e', 'Ä&#x2030;' => 'c',
  982. '?&#x203A;' => 's', '?Ž' => 'i', '??' => 'u', 'Ä&#x2021;' => 'c', 'Ä&#x2122;' => 'e', '??' => 'w', 'áš?' => 't',
  983. '??' => 'u', 'Ä?' => 'c', '??' => 'oe', '?¨' => 'e', '??' => 'y', 'Ä&#x2026;' => 'a', '?&#x201A;' => 'l',
  984. '??' => 'u', '??' => 'u', '?&#x;' => 's', 'Ä&#x;' => 'g', 'Ä?' => 'l', '?&#x2019;' => 'f', '?ž' => 'z',
  985. 'á?&#x192;' => 'w', 'á¸&#x192;' => 'b', '??' => 'a', '??' => 'i', '??' => 'i', 'á¸&#x2039;' => 'd', '??' => 't',
  986. '?&#x2014;' => 'r', '?¤' => 'ae', '?­' => 'i', '?&#x2022;' => 'r', '??' => 'e', '??' => 'ue', '??' => 'o',
  987. 'Ä&#x201C;' => 'e', '??' => 'n', '?&#x201E;' => 'n', 'Ä?' => 'h', 'Ä?' => 'g', 'Ä&#x2018;' => 'd', 'Ä?' => 'j',
  988. '??' => 'y', '?Š' => 'u', '?­' => 'u', '?°' => 'u', '??' => 't', '??' => 'y', '?&#x2018;' => 'o',
  989. '??' => 'a', 'Ğ' => 'l', 'á?&#x2026;' => 'w', '??' => 'z', 'Ä?' => 'i', '??' => 'a', 'Ä?' => 'g',
  990. 'ᚠ' => 'm', '??' => 'o', 'Ċ' => 'i', '?š' => 'u', 'Ä?' => 'i', '??' => 'z', '??' => 'a',
  991. '??' => 'u', '?ž' => 'th', '?°' => 'dh', '??' => 'ae', 'Â?' => 'u', 'Ä&#x2022;' => 'e',
  992. );
  993. /**
  994. * UTF-8 lookup table for upper case accented letters
  995. *
  996. * This lookuptable defines replacements for accented characters from the ASCII-7
  997. * range. This are upper case letters only.
  998. *
  999. * @author Andreas Gohr <andi@splitbrain.org>
  1000. * @see utf8_deaccent()
  1001. */
  1002. global $UTF8_UPPER_ACCENTS;
  1003. if(empty($UTF8_UPPER_ACCENTS)) $UTF8_UPPER_ACCENTS = array(
  1004. '?&#x20AC;' => 'A', '?&#x201D;' => 'O', 'Ä&#x17D;' => 'D', 'á¸&#x17E;' => 'F', '?&#x2039;' => 'E', '? ' => 'S', '? ' => 'O',
  1005. 'Ä&#x201A;' => 'A', '?&#x2DC;' => 'R', '?&#x161;' => 'T', '?&#x2021;' => 'N', 'Ä&#x20AC;' => 'A', 'Ä?' => 'K',
  1006. '?&#x153;' => 'S', 'á??' => 'Y', '?&#x2026;' => 'N', 'Ě' => 'L', 'Ä?' => 'H', 'áš&#x2013;' => 'P', '?&#x201C;' => 'O',
  1007. '?&#x161;' => 'U', 'Ä&#x161;' => 'E', '?&#x2030;' => 'E', '?&#x2021;' => 'C', 'á?&#x20AC;' => 'W', 'Ä&#x160;' => 'C', '?&#x2022;' => 'O',
  1008. 'ᚠ' => 'S', '?&#x2DC;' => 'O', 'Ä?' => 'G', '??' => 'T', '?&#x2DC;' => 'S', 'Ä&#x2013;' => 'E', 'Ä&#x2C6;' => 'C',
  1009. '?&#x161;' => 'S', '?&#x17D;' => 'I', '?°' => 'U', 'Ä&#x2020;' => 'C', 'Ä&#x2DC;' => 'E', '?´' => 'W', 'áš?' => 'T',
  1010. '??' => 'U', 'Ä&#x152;' => 'C', '?&#x2013;' => 'Oe', '?&#x2C6;' => 'E', '??' => 'Y', 'Ä&#x201E;' => 'A', '? ' => 'L',
  1011. '??' => 'U', '?Ž' => 'U', '?&#x17E;' => 'S', 'Ä&#x17E;' => 'G', 'Ä?' => 'L', '?&#x2018;' => 'F', '??' => 'Z',
  1012. 'á?&#x201A;' => 'W', 'á¸&#x201A;' => 'B', '?&#x2026;' => 'A', '?&#x152;' => 'I', '??' => 'I', 'á¸&#x160;' => 'D', '?¤' => 'T',
  1013. '?&#x2013;' => 'R', '?&#x201E;' => 'Ae', '??' => 'I', '?&#x201D;' => 'R', '?&#x160;' => 'E', '?&#x153;' => 'Ue', '?&#x2019;' => 'O',
  1014. 'Ä&#x2019;' => 'E', '?&#x2018;' => 'N', '?&#x192;' => 'N', 'Ĥ' => 'H', 'Ä&#x153;' => 'G', 'Ä?' => 'D', 'Ä´' => 'J',
  1015. '?¸' => 'Y', '?¨' => 'U', '??' => 'U', '??' => 'U', '??' => 'T', '??' => 'Y', '??' => 'O',
  1016. '?&#x201A;' => 'A', 'Ä?' => 'L', 'á?&#x201E;' => 'W', '??' => 'Z', 'Ä?' => 'I', '?&#x192;' => 'A', 'Ä ' => 'G',
  1017. 'áš&#x20AC;' => 'M', '?&#x152;' => 'O', 'Ĩ' => 'I', '?&#x2122;' => 'U', 'Ď' => 'I', '?š' => 'Z', '? ' => 'A',
  1018. '?&#x203A;' => 'U', '?&#x17E;' => 'Th', '??' => 'Dh', '?&#x2020;' => 'Ae', 'Ä&#x201D;' => 'E',
  1019. );
  1020. /**
  1021. * UTF-8 array of common special characters
  1022. *
  1023. * This array should contain all special characters (not a letter or digit)
  1024. * defined in the various local charsets - it's not a complete list of non-alphanum
  1025. * characters in UTF-8. It's not perfect but should match most cases of special
  1026. * chars.
  1027. *
  1028. * The controlchars 0x00 to 0x19 are _not_ included in this array. The space 0x20 is!
  1029. * These chars are _not_ in the array either: _ (0x5f), : 0x3a, . 0x2e, - 0x2d, * 0x2a
  1030. *
  1031. * @author Andreas Gohr <andi@splitbrain.org>
  1032. * @see utf8_stripspecials()
  1033. */
  1034. global $UTF8_SPECIAL_CHARS;
  1035. if(empty($UTF8_SPECIAL_CHARS)) $UTF8_SPECIAL_CHARS = array(
  1036. 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f, 0x0020, 0x0021, 0x0022, 0x0023,
  1037. 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002b, 0x002c,
  1038. 0x002f, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f, 0x0040, 0x005b,
  1039. 0x005c, 0x005d, 0x005e, 0x0060, 0x007b, 0x007c, 0x007d, 0x007e,
  1040. 0x007f, 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088,
  1041. 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f, 0x0090, 0x0091, 0x0092,
  1042. 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c,
  1043. 0x009d, 0x009e, 0x009f, 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6,
  1044. 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, 0x00b0,
  1045. 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba,
  1046. 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, 0x00d7, 0x00f7, 0x02c7, 0x02d8, 0x02d9,
  1047. 0x02da, 0x02db, 0x02dc, 0x02dd, 0x0300, 0x0301, 0x0303, 0x0309, 0x0323, 0x0384,
  1048. 0x0385, 0x0387, 0x03c6, 0x03d1, 0x03d2, 0x03d5, 0x03d6, 0x05b0, 0x05b1,
  1049. 0x05b2, 0x05b3, 0x05b4, 0x05b5, 0x05b6, 0x05b7, 0x05b8, 0x05b9, 0x05bb, 0x05bc,
  1050. 0x05bd, 0x05be, 0x05bf, 0x05c0, 0x05c1, 0x05c2, 0x05c3, 0x05f3, 0x05f4, 0x060c,
  1051. 0x061b, 0x061f, 0x0640, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f, 0x0650, 0x0651,
  1052. 0x0652, 0x066a, 0x0e3f, 0x200c, 0x200d, 0x200e, 0x200f, 0x2013, 0x2014, 0x2015,
  1053. 0x2017, 0x2018, 0x2019, 0x201a, 0x201c, 0x201d, 0x201e, 0x2020, 0x2021, 0x2022,
  1054. 0x2026, 0x2030, 0x2032, 0x2033, 0x2039, 0x203a, 0x2044, 0x20a7, 0x20aa, 0x20ab,
  1055. 0x20ac, 0x2116, 0x2118, 0x2122, 0x2126, 0x2135, 0x2190, 0x2191, 0x2192, 0x2193,
  1056. 0x2194, 0x2195, 0x21b5, 0x21d0, 0x21d1, 0x21d2, 0x21d3, 0x21d4, 0x2200, 0x2202,
  1057. 0x2203, 0x2205, 0x2206, 0x2207, 0x2208, 0x2209, 0x220b, 0x220f, 0x2211, 0x2212,
  1058. 0x2215, 0x2217, 0x2219, 0x221a, 0x221d, 0x221e, 0x2220, 0x2227, 0x2228, 0x2229,
  1059. 0x222a, 0x222b, 0x2234, 0x223c, 0x2245, 0x2248, 0x2260, 0x2261, 0x2264, 0x2265,
  1060. 0x2282, 0x2283, 0x2284, 0x2286, 0x2287, 0x2295, 0x2297, 0x22a5, 0x22c5, 0x2310,
  1061. 0x2320, 0x2321, 0x2329, 0x232a, 0x2469, 0x2500, 0x2502, 0x250c, 0x2510, 0x2514,
  1062. 0x2518, 0x251c, 0x2524, 0x252c, 0x2534, 0x253c, 0x2550, 0x2551, 0x2552, 0x2553,
  1063. 0x2554, 0x2555, 0x2556, 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d,
  1064. 0x255e, 0x255f, 0x2560, 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567,
  1065. 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x2580, 0x2584, 0x2588, 0x258c, 0x2590,
  1066. 0x2591, 0x2592, 0x2593, 0x25a0, 0x25b2, 0x25bc, 0x25c6, 0x25ca, 0x25cf, 0x25d7,
  1067. 0x2605, 0x260e, 0x261b, 0x261e, 0x2660, 0x2663, 0x2665, 0x2666, 0x2701, 0x2702,
  1068. 0x2703, 0x2704, 0x2706, 0x2707, 0x2708, 0x2709, 0x270c, 0x270d, 0x270e, 0x270f,
  1069. 0x2710, 0x2711, 0x2712, 0x2713, 0x2714, 0x2715, 0x2716, 0x2717, 0x2718, 0x2719,
  1070. 0x271a, 0x271b, 0x271c, 0x271d, 0x271e, 0x271f, 0x2720, 0x2721, 0x2722, 0x2723,
  1071. 0x2724, 0x2725, 0x2726, 0x2727, 0x2729, 0x272a, 0x272b, 0x272c, 0x272d, 0x272e,
  1072. 0x272f, 0x2730, 0x2731, 0x2732, 0x2733, 0x2734, 0x2735, 0x2736, 0x2737, 0x2738,
  1073. 0x2739, 0x273a, 0x273b, 0x273c, 0x273d, 0x273e, 0x273f, 0x2740, 0x2741, 0x2742,
  1074. 0x2743, 0x2744, 0x2745, 0x2746, 0x2747, 0x2748, 0x2749, 0x274a, 0x274b, 0x274d,
  1075. 0x274f, 0x2750, 0x2751, 0x2752, 0x2756, 0x2758, 0x2759, 0x275a, 0x275b, 0x275c,
  1076. 0x275d, 0x275e, 0x2761, 0x2762, 0x2763, 0x2764, 0x2765, 0x2766, 0x2767, 0x277f,
  1077. 0x2789, 0x2793, 0x2794, 0x2798, 0x2799, 0x279a, 0x279b, 0x279c, 0x279d, 0x279e,
  1078. 0x279f, 0x27a0, 0x27a1, 0x27a2, 0x27a3, 0x27a4, 0x27a5, 0x27a6, 0x27a7, 0x27a8,
  1079. 0x27a9, 0x27aa, 0x27ab, 0x27ac, 0x27ad, 0x27ae, 0x27af, 0x27b1, 0x27b2, 0x27b3,
  1080. 0x27b4, 0x27b5, 0x27b6, 0x27b7, 0x27b8, 0x27b9, 0x27ba, 0x27bb, 0x27bc, 0x27bd,
  1081. 0x27be, 0x3000, 0x3001, 0x3002, 0x3003, 0x3008, 0x3009, 0x300a, 0x300b, 0x300c,
  1082. 0x300d, 0x300e, 0x300f, 0x3010, 0x3011, 0x3012, 0x3014, 0x3015, 0x3016, 0x3017,
  1083. 0x3018, 0x3019, 0x301a, 0x301b, 0x3036,
  1084. 0xf6d9, 0xf6da, 0xf6db, 0xf8d7, 0xf8d8, 0xf8d9, 0xf8da, 0xf8db, 0xf8dc,
  1085. 0xf8dd, 0xf8de, 0xf8df, 0xf8e0, 0xf8e1, 0xf8e2, 0xf8e3, 0xf8e4, 0xf8e5, 0xf8e6,
  1086. 0xf8e7, 0xf8e8, 0xf8e9, 0xf8ea, 0xf8eb, 0xf8ec, 0xf8ed, 0xf8ee, 0xf8ef, 0xf8f0,
  1087. 0xf8f1, 0xf8f2, 0xf8f3, 0xf8f4, 0xf8f5, 0xf8f6, 0xf8f7, 0xf8f8, 0xf8f9, 0xf8fa,
  1088. 0xf8fb, 0xf8fc, 0xf8fd, 0xf8fe, 0xfe7c, 0xfe7d,
  1089. 0xff01, 0xff02, 0xff03, 0xff04, 0xff05, 0xff06, 0xff07, 0xff08, 0xff09,
  1090. 0xff09, 0xff0a, 0xff0b, 0xff0c, 0xff0d, 0xff0e, 0xff0f, 0xff1a, 0xff1b, 0xff1c,
  1091. 0xff1d, 0xff1e, 0xff1f, 0xff20, 0xff3b, 0xf