35 if ( substr( $to, -8 ) ==
'//IGNORE' ) {
36 $to = substr( $to, 0, strlen( $to ) - 8 );
38 if ( strcasecmp(
$from, $to ) == 0 ) {
41 if ( strcasecmp(
$from,
'utf-8' ) == 0 ) {
42 return utf8_decode( $string );
44 if ( strcasecmp( $to,
'utf-8' ) == 0 ) {
45 return utf8_encode( $string );
69 $str = substr( $str, $split );
74 $str = substr( $str, 0, $split );
86 if ( $splitPos == 0 ) {
90 $byteLen = strlen( $str );
92 if ( $splitPos > 0 ) {
93 if ( $splitPos > 256 ) {
98 while ( $bytePos < $byteLen && $str[$bytePos] >=
"\x80" && $str[$bytePos] <
"\xc0" ) {
101 $charPos =
mb_strlen( substr( $str, 0, $bytePos ) );
107 while ( $charPos++ < $splitPos ) {
110 while ( $bytePos < $byteLen && $str[$bytePos] >=
"\x80" && $str[$bytePos] <
"\xc0" ) {
115 $splitPosX = $splitPos + 1;
118 while ( $bytePos > 0 && $charPos-- >= $splitPosX ) {
121 while ( $bytePos > 0 && $str[$bytePos] >=
"\x80" && $str[$bytePos] <
"\xc0" ) {
137 $counts = count_chars( $str );
141 for ( $i = 0; $i < 0x80; $i++ ) {
146 for ( $i = 0xc0; $i < 0xff; $i++ ) {
160 public static function mb_strpos( $haystack, $needle, $offset = 0, $encoding =
'' ) {
161 $needle = preg_quote( $needle,
'/' );
164 preg_match(
'/' . $needle .
'/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
166 if ( isset( $ar[0][1] ) ) {
181 public static function mb_strrpos( $haystack, $needle, $offset = 0, $encoding =
'' ) {
182 $needle = preg_quote( $needle,
'/' );
185 preg_match_all(
'/' . $needle .
'/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
187 if ( isset( $ar[0] ) && count( $ar[0] ) > 0 &&
188 isset( $ar[0][count( $ar[0] ) - 1][1] ) ) {
189 return $ar[0][count( $ar[0] ) - 1][1];