Changeset 36018 for trunk/src/wp-includes/compat.php
- Timestamp:
- 12/19/2015 04:49:42 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/compat.php
r36017 r36018 83 83 } 84 84 85 // The solution below works only for UTF-8, 86 // so in case of a different charset just use built-in substr() 85 /* 86 * The solution below works only for UTF-8, so in case of a different 87 * charset just use built-in substr(). 88 */ 87 89 if ( ! in_array( $encoding, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) { 88 90 return is_null( $length ) ? substr( $str, $start ) : substr( $str, $start, $length ); … … 90 92 91 93 if ( _wp_can_use_pcre_u() ) { 92 // Use the regex unicode support to separate the UTF-8 characters into an array 94 // Use the regex unicode support to separate the UTF-8 characters into an array. 93 95 preg_match_all( '/./us', $str, $match ); 94 96 $chars = is_null( $length ) ? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length ); … … 108 110 )/x'; 109 111 110 $chars = array( '' ); // Start with 1 element instead of 0 since the first thing we do is pop 112 // Start with 1 element instead of 0 since the first thing we do is pop. 113 $chars = array( '' ); 111 114 do { 112 115 // We had some string left over from the last round, but we counted it in that last round. 113 116 array_pop( $chars ); 114 117 115 // Split by UTF-8 character, limit to 1000 characters (last array element will contain the rest of the string) 118 /* 119 * Split by UTF-8 character, limit to 1000 characters (last array element will contain 120 * the rest of the string). 121 */ 116 122 $pieces = preg_split( $regex, $str, 1000, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); 117 123 118 124 $chars = array_merge( $chars, $pieces ); 119 } while ( count( $pieces ) > 1 && $str = array_pop( $pieces ) ); // If there's anything left over, repeat the loop. 125 126 // If there's anything left over, repeat the loop. 127 } while ( count( $pieces ) > 1 && $str = array_pop( $pieces ) ); 120 128 121 129 return join( '', array_slice( $chars, $start, $length ) );
Note: See TracChangeset
for help on using the changeset viewer.