Changeset 52482 for branches/4.1/src/wp-includes/formatting.php
- Timestamp:
- 01/06/2022 06:23:29 PM (3 years ago)
- Location:
- branches/4.1
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.1
- Property svn:mergeinfo changed
/trunk merged: 52454-52457
- Property svn:mergeinfo changed
-
branches/4.1/src/wp-includes/formatting.php
r47658 r52482 864 864 * 865 865 * @since 1.5.0 866 * @since 5.8.3 Added the `encode_ascii_characters` parameter. 866 867 * 867 868 * @param string $utf8_string 868 869 * @param int $length Max length of the string 870 * @param bool $encode_ascii_characters Whether to encode ascii characters such as < " ' 869 871 * @return string String with Unicode encoded for URI. 870 872 */ 871 function utf8_uri_encode( $utf8_string, $length = 0 ) {873 function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) { 872 874 $unicode = ''; 873 875 $values = array(); … … 884 886 885 887 if ( $value < 128 ) { 886 if ( $length && ( $unicode_length >= $length ) ) 888 $char = chr( $value ); 889 $encoded_char = $encode_ascii_characters ? rawurlencode( $char ) : $char; 890 $encoded_char_length = strlen( $encoded_char ); 891 if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) { 887 892 break; 888 $unicode .= chr($value); 889 $unicode_length++; 893 } 894 $unicode .= $encoded_char; 895 $unicode_length += $encoded_char_length; 890 896 } else { 891 897 if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
Note: See TracChangeset
for help on using the changeset viewer.