(bug 32748) unicode URL for articles print version
[lhc/web/wiklou.git] / includes / GlobalFunctions.php
index e9f22de..bcbcefe 100644 (file)
@@ -802,6 +802,31 @@ function wfParseUrl( $url ) {
        return $bits;
 }
 
+/**
+ * Take a URL, make sure it's expanded to fully qualified, and replace any
+ * encoded non-ASCII Unicode characters with their UTF-8 original forms
+ * for more compact display and legibility for local audiences.
+ *
+ * @todo handle punycode domains too
+ *
+ * @param $url string
+ * @return string
+ */
+function wfExpandIRI( $url ) {
+       return preg_replace_callback( '/((?:%[89A-F][0-9A-F])+)/i', 'wfExpandIRI_callback', wfExpandUrl( $url ) );
+}
+
+/**
+ * Private callback for wfExpandIRI
+ * @param array $matches
+ * @return string
+ */
+function wfExpandIRI_callback( $matches ) {
+       return urldecode( $matches[1] );
+}
+
+
+
 /**
  * Make URL indexes, appropriate for the el_index field of externallinks.
  *