From 049108e6ca48231853f1ecdd01974b0c11ed6f94 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Sat, 30 Nov 2013 15:19:41 -0500 Subject: [PATCH] Fix for issue 330 - "Tag list does not handle non-english text correctly". --- ext/tag_list/main.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index e3990e9b..7209beac 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -243,12 +243,28 @@ class TagList extends Extension { $html = ""; if($config->get_bool("tag_list_pages")) $html .= $this->build_az(); + + /* + strtolower() vs. mb_strtolower() + ( See http://www.php.net/manual/en/function.mb-strtolower.php for more info ) + + PHP5's strtolower function does not support Unicode (UTF-8) properly, so + you have to use another function, mb_strtolower, to handle UTF-8 strings. + + What's worse is that mb_strtolower is horribly SLOW. + + It would probably be better to have a config option for the Tag List that + would allow you to specify if there are UTF-8 tags. + + */ + mb_internal_encoding('UTF-8'); + $lastLetter = ""; foreach($tag_data as $row) { $h_tag = html_escape($row['tag']); $count = $row['count']; - if($lastLetter != strtolower(substr($h_tag, 0, count($starts_with)+1))) { - $lastLetter = strtolower(substr($h_tag, 0, count($starts_with)+1)); + if($lastLetter != mb_strtolower(substr($h_tag, 0, count($starts_with)+1))) { + $lastLetter = mb_strtolower(substr($h_tag, 0, count($starts_with)+1)); $html .= "<p>$lastLetter<br>"; } $link = $this->tag_link($row['tag']);