Changeset 52485 for branches/3.8/src/wp-includes/formatting.php
- Timestamp:
- 01/06/2022 06:26:53 PM (3 years ago)
- Location:
- branches/3.8
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.8
- Property svn:mergeinfo changed
/trunk merged: 52454,52456-52457
- Property svn:mergeinfo changed
-
branches/3.8/src/wp-includes/formatting.php
r47661 r52485 678 678 * 679 679 * @since 1.5.0 680 * @since 5.8.3 Added the `encode_ascii_characters` parameter. 680 681 * 681 682 * @param string $utf8_string 682 683 * @param int $length Max length of the string 684 * @param bool $encode_ascii_characters Whether to encode ascii characters such as < " ' 683 685 * @return string String with Unicode encoded for URI. 684 686 */ 685 function utf8_uri_encode( $utf8_string, $length = 0 ) {687 function utf8_uri_encode( $utf8_string, $length = 0, $encode_ascii_characters = false ) { 686 688 $unicode = ''; 687 689 $values = array(); … … 695 697 696 698 if ( $value < 128 ) { 697 if ( $length && ( $unicode_length >= $length ) ) 699 $char = chr( $value ); 700 $encoded_char = $encode_ascii_characters ? rawurlencode( $char ) : $char; 701 $encoded_char_length = strlen( $encoded_char ); 702 if ( $length && ( $unicode_length + $encoded_char_length ) > $length ) { 698 703 break; 699 $unicode .= chr($value); 700 $unicode_length++; 704 } 705 $unicode .= $encoded_char; 706 $unicode_length += $encoded_char_length; 701 707 } else { 702 708 if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
Note: See TracChangeset
for help on using the changeset viewer.