diff options
Diffstat (limited to 'includes/normal/UtfNormalUtil.php')
-rw-r--r-- | includes/normal/UtfNormalUtil.php | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/includes/normal/UtfNormalUtil.php b/includes/normal/UtfNormalUtil.php index bfad7095..e8fec936 100644 --- a/includes/normal/UtfNormalUtil.php +++ b/includes/normal/UtfNormalUtil.php @@ -71,14 +71,16 @@ function hexSequenceToUtf8( $sequence ) { * Take a UTF-8 string and return a space-separated series of hex * numbers representing Unicode code points. For debugging. * - * @param $str String: UTF-8 string. + * @param string $str UTF-8 string. * @return string * @private */ function utf8ToHexSequence( $str ) { - return rtrim( preg_replace( '/(.)/uSe', - 'sprintf("%04x ", utf8ToCodepoint("$1"))', - $str ) ); + $buf = ''; + foreach ( preg_split( '//u', $str, -1, PREG_SPLIT_NO_EMPTY ) as $cp ) { + $buf .= sprintf( '%04x ', utf8ToCodepoint( $cp ) ); + } + return rtrim( $buf ); } /** @@ -114,7 +116,7 @@ function utf8ToCodepoint( $char ) { $z >>= $length; # Add in the free bits from subsequent bytes - for ( $i=1; $i<$length; $i++ ) { + for ( $i=1; $i < $length; $i++ ) { $z <<= 6; $z |= ord( $char[$i] ) & 0x3f; } @@ -125,7 +127,7 @@ function utf8ToCodepoint( $char ) { /** * Escape a string for inclusion in a PHP single-quoted string literal. * - * @param $string String: string to be escaped. + * @param string $string string to be escaped. * @return String: escaped string. * @public */ |