Skip to content
Snippets Groups Projects
Commit 7077c942 authored by andi's avatar andi
Browse files

utf8 substr replacement

darcs-hash:20050123163344-9977f-38c3f78a3b76ab0e7f181698cb79711b5d3469c1.gz
parent 93a9e835
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment