Changeset 52483 for branches/4.0/src/wp-includes/formatting.php
- Timestamp:
- 01/06/2022 06:25:11 PM (3 years ago)
- Location:
- branches/4.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.0
- Property svn:mergeinfo changed
/trunk merged: 52454,52456-52457
- Property svn:mergeinfo changed
-
branches/4.0/src/wp-includes/formatting.php
r47659 r52483 859 859 * 860 860 * @since 1.5.0 861 * @since 5.8.3 Added the `encode_ascii_characters` parameter. 861 862 * 862 863 * @param string $utf8_string 863 864 * @param int $length Max length of the string 865 * @param bool $encode_ascii_characters Whether to encode ascii characters such as < " ' 864 866 * @return string String with Unicode encoded for URI. 865 867 */ 866 function utf8_uri_encode( $utf8_string, $length = 0 ) {868 function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) { 867 869 $unicode = ''; 868 870 $values = array(); … … 879 881 880 882 if ( $value < 128 ) { 881 if ( $length && ( $unicode_length >= $length ) ) 883 $char = chr( $value ); 884 $encoded_char = $encode_ascii_characters ? rawurlencode( $char ) : $char; 885 $encoded_char_length = strlen( $encoded_char ); 886 if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) { 882 887 break; 883 $unicode .= chr($value); 884 $unicode_length++; 888 } 889 $unicode .= $encoded_char; 890 $unicode_length += $encoded_char_length; 885 891 } else { 886 892 if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
Note: See TracChangeset
for help on using the changeset viewer.