Changeset 52467 for branches/5.6/src/wp-includes/formatting.php
- Timestamp:
- 01/06/2022 05:55:41 PM (3 years ago)
- Location:
- branches/5.6
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.6
- Property svn:mergeinfo changed
/trunk merged: 52454-52457
- Property svn:mergeinfo changed
-
branches/5.6/src/wp-includes/formatting.php
r49513 r52467 1139 1139 * 1140 1140 * @since 1.5.0 1141 * 1142 * @param string $utf8_string 1143 * @param int $length Max length of the string 1141 * @since 5.8.3 Added the `encode_ascii_characters` parameter. 1142 * 1143 * @param string $utf8_string String to encode. 1144 * @param int $length Max length of the string 1145 * @param bool $encode_ascii_characters Whether to encode ascii characters such as < " ' 1144 1146 * @return string String with Unicode encoded for URI. 1145 1147 */ 1146 function utf8_uri_encode( $utf8_string, $length = 0 ) {1148 function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) { 1147 1149 $unicode = ''; 1148 1150 $values = array(); … … 1159 1161 1160 1162 if ( $value < 128 ) { 1161 if ( $length && ( $unicode_length >= $length ) ) { 1163 $char = chr( $value ); 1164 $encoded_char = $encode_ascii_characters ? rawurlencode( $char ) : $char; 1165 $encoded_char_length = strlen( $encoded_char ); 1166 if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) { 1162 1167 break; 1163 1168 } 1164 $unicode .= chr( $value );1165 $unicode_length ++;1169 $unicode .= $encoded_char; 1170 $unicode_length += $encoded_char_length; 1166 1171 } else { 1167 1172 if ( count( $values ) == 0 ) {
Note: See TracChangeset
for help on using the changeset viewer.