public function utf8_to_ascii_test()
 {
     $this->assert_equal("Te glossa mou edosan ellenike", transliterate::utf8_to_ascii("Τη γλώσσα μου έδωσαν ελληνική"));
     $this->assert_equal("Na bierieghu pustynnykh voln", transliterate::utf8_to_ascii("На берегу пустынных волн"));
     $this->assert_equal("vepxis tqaosani shot`a rust`aveli", transliterate::utf8_to_ascii("ვეპხის ტყაოსანი შოთა რუსთაველი"));
     $this->assert_equal("WoNengTunXiaBoLiErBuShangShenTi", transliterate::utf8_to_ascii("我能吞下玻璃而不伤身体"));
 }
Example #2
0
 /**
  * Convert a filename into something we can use as a url component.
  * @param string $filename
  */
 static function convert_filename_to_slug($filename)
 {
     $result = str_replace("&", "-and-", $filename);
     $result = str_replace(" ", "-", $result);
     // It's not easy to extend the text helper since it's called by the Input class which is
     // referenced in hooks/init_gallery, so it's
     if (class_exists("transliterate")) {
         $result = transliterate::utf8_to_ascii($result);
     } else {
         $result = text::transliterate_to_ascii($result);
     }
     $result = preg_replace("/[^A-Za-z0-9-_]+/", "-", $result);
     $result = preg_replace("/-+/", "-", $result);
     return trim($result, "-");
 }