Changeset 52475 for branches/4.8/src/wp-includes/formatting.php
- Timestamp:
- 01/06/2022 06:14:56 PM (3 years ago)
- Location:
- branches/4.8
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.8
- Property svn:mergeinfo changed
/trunk merged: 52454-52457
- Property svn:mergeinfo changed
-
branches/4.8/src/wp-includes/formatting.php
r49398 r52475 1071 1071 * 1072 1072 * @since 1.5.0 1073 * 1074 * @param string $utf8_string 1075 * @param int $length Max length of the string 1073 * @since 5.8.3 Added the `encode_ascii_characters` parameter. 1074 * 1075 * @param string $utf8_string String to encode. 1076 * @param int $length Max length of the string 1077 * @param bool $encode_ascii_characters Whether to encode ascii characters such as < " ' 1076 1078 * @return string String with Unicode encoded for URI. 1077 1079 */ 1078 function utf8_uri_encode( $utf8_string, $length = 0 ) {1080 function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) { 1079 1081 $unicode = ''; 1080 1082 $values = array(); … … 1091 1093 1092 1094 if ( $value < 128 ) { 1093 if ( $length && ( $unicode_length >= $length ) ) { 1095 $char = chr( $value ); 1096 $encoded_char = $encode_ascii_characters ? rawurlencode( $char ) : $char; 1097 $encoded_char_length = strlen( $encoded_char ); 1098 if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) { 1094 1099 break; 1095 1100 } 1096 $unicode .= chr( $value );1097 $unicode_length ++;1101 $unicode .= $encoded_char; 1102 $unicode_length += $encoded_char_length; 1098 1103 } else { 1099 1104 if ( count( $values ) == 0 ) {
Note: See TracChangeset
for help on using the changeset viewer.