utf8 substr replacement
darcs-hash:20050123163344-9977f-38c3f78a3b76ab0e7f181698cb79711b5d3469c1.gz
This commit is contained in:
parent
93a9e83512
commit
7077c942d0
15
inc/utf8.php
15
inc/utf8.php
|
@ -69,6 +69,21 @@ function utf8_strlen($string){
|
|||
return count($uni);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a unicode aware replacement for substr()
|
||||
*
|
||||
* Uses mb_string extension if available
|
||||
*
|
||||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
* @see substr()
|
||||
*/
|
||||
function utf8_substr($str, $start, $length=null){
|
||||
if(!defined('UTF8_NOMBSTRING') && function_exists('mb_substr'))
|
||||
return mb_substr($str,$start,$length,'utf-8');
|
||||
|
||||
$uni = utf8_to_unicode($str);
|
||||
return unicode_to_utf8(array_slice($uni,$start,$length));
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a unicode aware replacement for strtolower()
|
||||
|
|
Loading…
Reference in New Issue