diff --git a/lib/settings.php b/lib/settings.php index c71f9b4..8cc8684 100644 --- a/lib/settings.php +++ b/lib/settings.php @@ -53,6 +53,8 @@ function numClean($var) { // returns a UTF8 based string with any UFT8 BOM removed function toUTF8noBOM($string,$message) { + // Attempt to detect encoding + $encType = mb_detect_encoding($string); // Get rid of any UTF-8 BOM $string = preg_replace('/\x{EF}\x{BB}\x{BF}/','',$string); // Test for any bad characters @@ -60,7 +62,7 @@ function toUTF8noBOM($string,$message) { $teststringBroken = utf8_decode($teststring); $teststringConverted = iconv("UTF-8", "UTF-8//IGNORE", $teststringBroken); // If we have a matching length, UTF8 encode it - if (strlen($teststringConverted) == strlen($teststringBroken)) { + if ($encType != "ASCII" && strlen($teststringConverted) == strlen($teststringBroken)) { $string = utf8_encode($string); if ($message) { echo "";