summaryrefslogtreecommitdiff
path: root/it_html.class
diff options
context:
space:
mode:
Diffstat (limited to 'it_html.class')
-rw-r--r--it_html.class17
1 files changed, 7 insertions, 10 deletions
diff --git a/it_html.class b/it_html.class
index 41d799f..71ac965 100644
--- a/it_html.class
+++ b/it_html.class
@@ -259,18 +259,15 @@ function _parse_args($args)
# internal
-function fix_encoding($string)
+function fix_encoding($string, $silent = false)
{
if (preg_match('/[\x20-\x7f][\x80-\xff][\x20-\x7f]/', $string))
- {
- it::error(array('title' => utf8_encode("incorrectly utf8-encoded: " . trim($string)), 'skipfiles' => "it_html"));
- $string = utf8_encode($string);
- }
- else if ($string && preg_match('/[\x80-\xff]/', $string) && htmlspecialchars(utf8_decode($string), ENT_COMPAT, "utf-8") !== "")
- {
- it::error(array('title' => utf8_encode("doubly utf8-encoded: " . trim($string)), 'skipfiles' => "it_html"));
- $string = utf8_decode($string);
- }
+ list($string, $error) = array(utf8_encode($string), utf8_encode("incorrectly utf8-encoded: " . trim($string)));
+ else if ($string && preg_match('/[\x80-\xff]/', $string) && utf8_encode(utf8_decode($string)) === $string && htmlspecialchars(utf8_decode($string), ENT_COMPAT, "utf-8") !== "")
+ list($string, $error) = array(utf8_decode($string), utf8_encode("doubly utf8-encoded: " . trim($string)));
+
+ if ($error && !$silent)
+ it::error(array('title' => $error, 'skipfiles' => "it_html"));
return $string;
}