Changeset 1345
- Timestamp:
- 05/22/2004 02:34:09 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions-formatting.php
r1336 r1345 79 79 } 80 80 81 82 function seems_utf8($Str) { # by bmorel at ssi dot fr 83 for ($i=0; $i<strlen($Str); $i++) { 84 if (ord($Str[$i]) < 0x80) continue; # 0bbbbbbb 85 elseif ((ord($Str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb 86 elseif ((ord($Str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb 87 elseif ((ord($Str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb 88 elseif ((ord($Str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb 89 elseif ((ord($Str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b 90 else return false; # Does not match any model 91 for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ? 92 if ((++$i == strlen($Str)) || ((ord($Str[$i]) & 0xC0) != 0x80)) 93 return false; 94 } 95 } 96 return true; 97 } 98 99 function remove_accents($string) { 100 $chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158) 101 .chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194) 102 .chr(195).chr(196).chr(197).chr(199).chr(200).chr(201).chr(202) 103 .chr(203).chr(204).chr(205).chr(206).chr(207).chr(209).chr(210) 104 .chr(211).chr(212).chr(213).chr(214).chr(216).chr(217).chr(218) 105 .chr(219).chr(220).chr(221).chr(224).chr(225).chr(226).chr(227) 106 .chr(228).chr(229).chr(231).chr(232).chr(233).chr(234).chr(235) 107 .chr(236).chr(237).chr(238).chr(239).chr(241).chr(242).chr(243) 108 .chr(244).chr(245).chr(246).chr(248).chr(249).chr(250).chr(251) 109 .chr(252).chr(253).chr(255); 110 $chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy"; 111 if (seems_utf8($string)) { 112 $invalid_latin_chars = array(chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', chr(197).chr(160) => 'S', chr(197).chr(189) => 'Z', chr(197).chr(161) => 's', chr(197).chr(190) => 'z', chr(226).chr(130).chr(172) => 'E'); 113 $string = utf8_decode(strtr($string, $invalid_latin_chars)); 114 } 115 $string = strtr($string, $chars['in'], $chars['out']); 116 $double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254)); 117 $double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th'); 118 $string = str_replace($double_chars['in'], $double_chars['out'], $string); 119 return $string; 120 } 121 81 122 function sanitize_title($title) { 82 123 $title = do_action('sanitize_title', $title); … … 86 127 87 128 function sanitize_title_with_dashes($title) { 129 $title = remove_accents($title); 88 130 $title = strtolower($title); 89 131 $title = preg_replace('/&.+?;/', '', $title); // kill entities
Note: See TracChangeset
for help on using the changeset viewer.