Changeset 52477 for branches/4.6/src/wp-includes/formatting.php
- Timestamp:
- 01/06/2022 06:16:25 PM (3 years ago)
- Location:
- branches/4.6
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.6
- Property svn:mergeinfo changed
/trunk merged: 52454-52457
- Property svn:mergeinfo changed
-
branches/4.6/src/wp-includes/formatting.php
r49400 r52477 1065 1065 * 1066 1066 * @since 1.5.0 1067 * 1068 * @param string $utf8_string 1069 * @param int $length Max length of the string 1067 * @since 5.8.3 Added the `encode_ascii_characters` parameter. 1068 * 1069 * @param string $utf8_string String to encode. 1070 * @param int $length Max length of the string 1071 * @param bool $encode_ascii_characters Whether to encode ascii characters such as < " ' 1070 1072 * @return string String with Unicode encoded for URI. 1071 1073 */ 1072 function utf8_uri_encode( $utf8_string, $length = 0 ) {1074 function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) { 1073 1075 $unicode = ''; 1074 1076 $values = array(); … … 1085 1087 1086 1088 if ( $value < 128 ) { 1087 if ( $length && ( $unicode_length >= $length ) ) { 1089 $char = chr( $value ); 1090 $encoded_char = $encode_ascii_characters ? rawurlencode( $char ) : $char; 1091 $encoded_char_length = strlen( $encoded_char ); 1092 if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) { 1088 1093 break; 1089 1094 } 1090 $unicode .= chr( $value );1091 $unicode_length ++;1095 $unicode .= $encoded_char; 1096 $unicode_length += $encoded_char_length; 1092 1097 } else { 1093 1098 if ( count( $values ) == 0 ) {
Note: See TracChangeset
for help on using the changeset viewer.