Add a utf-8 to hex sequence function for debugging
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 15 Nov 2004 00:58:36 +0000 (00:58 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 15 Nov 2004 00:58:36 +0000 (00:58 +0000)
includes/normal/UtfNormalUtil.php

index 53f2c36..06e0bb4 100644 (file)
@@ -68,6 +68,20 @@ function hexSequenceToUtf8( $sequence ) {
        return $utf;
 }
 
+/**
+ * Take a UTF-8 string and return a space-separated series of hex
+ * numbers representing Unicode code points. For debugging.
+ *
+ * @param string $str
+ * @return string
+ * @access private
+ */
+function utf8ToHexSequence( $str ) {
+       return rtrim( preg_replace( '/(.)/uSe',
+                                   'sprintf("%04x ", utf8ToCodepoint("$1"))',
+                                   $str ) );
+}
+
 /**
  * Determine the Unicode codepoint of a single-character UTF-8 sequence.
  * Does not check for invalid input data.