aboutsummaryrefslogtreecommitdiff
path: root/engine/classes
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2012-06-26 11:28:58 -0400
committerSteve Clay <steve@mrclay.org>2012-06-26 11:28:58 -0400
commit8a5ddacfa2598b8d984c2cdc6142d41936f38c48 (patch)
tree20878d37bcee06586228eab8c8da5d8ba381e47c /engine/classes
parent4fff20a33467a7318956412d4dabfcab1ce6daba (diff)
downloadelgg-8a5ddacfa2598b8d984c2cdc6142d41936f38c48.tar.gz
elgg-8a5ddacfa2598b8d984c2cdc6142d41936f38c48.tar.bz2
Added NFC conversion where available
Diffstat (limited to 'engine/classes')
-rw-r--r--engine/classes/ElggTranslit.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/engine/classes/ElggTranslit.php b/engine/classes/ElggTranslit.php
index 704c17f6a..809302276 100644
--- a/engine/classes/ElggTranslit.php
+++ b/engine/classes/ElggTranslit.php
@@ -37,6 +37,13 @@ class ElggTranslit {
static public function urlize($string, $separator = '-') {
// Iñtërnâtiônàlizætiøn, AND 日本語!
+ // try to force combined chars because the translit map and others expect it
+ if (self::hasNormalizerSupport()) {
+ $nfc = normalizer_normalize($string);
+ if (is_string($nfc)) {
+ $string = $nfc;
+ }
+ }
// Internationalization, AND 日本語!
$string = self::transliterateAscii($string);
@@ -235,4 +242,19 @@ class ElggTranslit {
"\xE1\xBB\xB4" /* Ỵ */ => 'Y', "\xE1\xBB\xB5" /* ỵ */ => 'y',
);
}
+
+ /**
+ * Tests that "normalizer_normalize" exists and works
+ * @return bool
+ */
+ static public function hasNormalizerSupport() {
+ static $ret = null;
+ if (null === $ret) {
+ $form_c = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5)
+ $form_d = "A\xCC\x8A"; // A followed by 'COMBINING RING ABOVE' (U+030A)
+ $ret = (function_exists('normalizer_normalize')
+ && $form_c === normalizer_normalize($form_d));
+ }
+ return $ret;
+ }
}