From c5fb1eb493238d6a6dbf23b324b1b3ce5f2d1573 Mon Sep 17 00:00:00 2001 From: Igor V Belousov Date: Wed, 16 Dec 2015 00:11:54 +0300 Subject: [PATCH] Fix Encode: remove mb_internal_encoding --- idna.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/idna.php b/idna.php index 5c4e297..ace0adb 100644 --- a/idna.php +++ b/idna.php @@ -61,9 +61,6 @@ function EncodePunycodeIDN( $value ) return substr( $sub_result, 1 ); } - $mb_internal_enc = mb_internal_encoding(); - mb_internal_encoding( "UTF-8" ); - /* http://tools.ietf.org/html/rfc3492#section-6.3 */ $n = 0x80; $delta = 0; @@ -72,10 +69,10 @@ function EncodePunycodeIDN( $value ) $input = array(); $str = $value; - while ( mb_strlen( $str ) > 0 ) + while ( mb_strlen( $str , 'UTF-8' ) > 0 ) { - array_push( $input, mb_substr( $str, 0, 1 ) ); - $str = mb_substr( $str, 1 ); + array_push( $input, mb_substr( $str, 0, 1, 'UTF-8' ) ); + $str = mb_substr( $str, 1, null, 'UTF-8' ); } /* basic symbols */ @@ -84,7 +81,6 @@ function EncodePunycodeIDN( $value ) if ( $b == $input ) { - mb_internal_encoding( $mb_internal_enc ); return $value; } $b = count( $b ); @@ -114,7 +110,6 @@ function EncodePunycodeIDN( $value ) } if ( ( $m - $n ) > ( 0x10FFFF / ( $h + 1 ) ) ) { - mb_internal_encoding( $mb_internal_enc ); return $value; } $delta += ( $m - $n ) * ( $h + 1 ); @@ -128,7 +123,6 @@ function EncodePunycodeIDN( $value ) ++$delta; if ( $delta == 0 ) { - mb_internal_encoding( $mb_internal_enc ); return $value; } } @@ -179,7 +173,6 @@ function EncodePunycodeIDN( $value ) ++$delta; ++$n; } - mb_internal_encoding( $mb_internal_enc ); return implode( '', $output ); }