summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
authorChad Parry <github@chad.parry.org>2011-06-25 14:13:25 -0600
committerChad Parry <github@chad.parry.org>2011-06-25 14:13:25 -0600
commit521a682837ab5b035d63160ea7b22540f3adf7b1 (patch)
tree2b7a7af221f92c6c470234731bbb05cb81ee07e7 /modules/gallery/helpers
parent20d7bfd6b904053c2bc27b69d32c71a321e0dae9 (diff)
parent771de0a3746ac0d780cb5dce2a14aa5a6ddf06d7 (diff)
Merge branch 'master' into rawphoto-squash
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/encoding.php17
1 files changed, 10 insertions, 7 deletions
diff --git a/modules/gallery/helpers/encoding.php b/modules/gallery/helpers/encoding.php
index c5928634..7d5add34 100644
--- a/modules/gallery/helpers/encoding.php
+++ b/modules/gallery/helpers/encoding.php
@@ -19,13 +19,16 @@
*/
class encoding_Core {
static function convert_to_utf8($value) {
- if (function_exists("mb_detect_encoding") &&
- function_exists("mb_convert_encoding") &&
- mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") {
- $value = mb_convert_encoding($value, "UTF-8", mb_detect_encoding($value));
- } else if (function_exists("mb_detect_encoding") &&
- mb_detect_encoding($value, "ISO-8859-1, UTF-8") != "UTF-8") {
- $value = utf8_encode($value);
+ if (function_exists("mb_detect_encoding")) {
+ // Rely on mb_detect_encoding()'s strict mode
+ $src_encoding = mb_detect_encoding($value, mb_detect_order(), true);
+ if ($src_encoding != "UTF-8") {
+ if (function_exists("mb_convert_encoding") && $src_encoding) {
+ $value = mb_convert_encoding($value, "UTF-8", $src_encoding);
+ } else {
+ $value = utf8_encode($value);
+ }
+ }
}
return $value;
}