Ticket #236: TextHelperUTF8.patch
| File TextHelperUTF8.patch, 1.3 kB (added by sasan, 14 months ago) |
|---|
-
libs/kohana/helpers/text.php
140 140 } 141 141 142 142 $str = ''; 143 $pool_size = utf8::strlen($pool);143 $pool_size = class_exists('utf8', FALSE) ? utf8::strlen($pool) : strlen($pool); 144 144 145 145 for ($i = 0; $i < $length; $i++) 146 146 { 147 $str .= utf8::substr($pool, mt_rand(0, $pool_size - 1), 1);147 $str .= class_exists('utf8', FALSE) ? utf8::substr($pool, mt_rand(0, $pool_size - 1), 1) : substr($pool, mt_rand(0, $pool_size - 1), 1); 148 148 } 149 149 150 150 return $str; … … 195 195 196 196 $regex = '!'.$regex.'!ui'; 197 197 198 if (utf8::strlen($replacement) == 1) 198 $strlen = class_exists('utf8', FALSE) ? utf8::strlen($replacement) : strlen($replacement); 199 200 if ($strlen == 1) 199 201 { 200 202 $regex .= 'e'; 201 return preg_replace($regex, 'str_repeat($replacement, utf8::strlen(\'$1\'))', $str);203 return preg_replace($regex, 'str_repeat($replacement, class_exists(\'utf8\', FALSE) ? utf8::strlen(\'$1\') : strlen(\'$1\'))', $str); 202 204 } 203 205 204 206 return preg_replace($regex, $replacement, $str); … … 247 249 return sprintf($format, $bytes / pow($mod, $power), $units[$power]); 248 250 } 249 251 250 } // End text 251 No newline at end of file 252 } // End text
