Changeset 52484 for branches/3.9/src/wp-includes/formatting.php
- Timestamp:
- 01/06/2022 06:25:42 PM (4 years ago)
- Location:
- branches/3.9
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/wp-includes/formatting.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.9
- Property svn:mergeinfo changed
/trunk merged: 52454,52456-52457
- Property svn:mergeinfo changed
-
branches/3.9/src/wp-includes/formatting.php
r47660 r52484 736 736 * 737 737 * @since 1.5.0 738 * @since 5.8.3 Added the `encode_ascii_characters` parameter. 738 739 * 739 740 * @param string $utf8_string 740 741 * @param int $length Max length of the string 742 * @param bool $encode_ascii_characters Whether to encode ascii characters such as < " ' 741 743 * @return string String with Unicode encoded for URI. 742 744 */ 743 function utf8_uri_encode( $utf8_string, $length = 0 ) {745 function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) { 744 746 $unicode = ''; 745 747 $values = array(); … … 753 755 754 756 if ( $value < 128 ) { 755 if ( $length && ( $unicode_length >= $length ) ) 757 $char = chr( $value ); 758 $encoded_char = $encode_ascii_characters ? rawurlencode( $char ) : $char; 759 $encoded_char_length = strlen( $encoded_char ); 760 if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) { 756 761 break; 757 $unicode .= chr($value); 758 $unicode_length++; 762 } 763 $unicode .= $encoded_char; 764 $unicode_length += $encoded_char_length; 759 765 } else { 760 766 if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
Note: See TracChangeset
for help on using the changeset viewer.