diff options
-rw-r--r-- | it_dbi.class | 4 | ||||
-rw-r--r-- | it_html.class | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/it_dbi.class b/it_dbi.class index ba0606c..ced925b 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -247,7 +247,11 @@ function _set($tags, $allfields = false) if (substr($field, 0, 1) == '-') # Unquoted value (always added) $r[] = substr($field, 1)."=$value"; else if ($allfields || ($value !== $this->_data[$field])) + { + if ($this->_p['charset'] == "utf8") # NOTE: Mysql charset is simply utf8, not utf-8 + $value = it_html::fix_encoding($value); $r[] = "`$field`=".(isset($value) ? $this->escape_string($value) : 'NULL'); + } } return $r ? 'SET '.implode(', ', $r) : ''; diff --git a/it_html.class b/it_html.class index f20c4be..91e3069 100644 --- a/it_html.class +++ b/it_html.class @@ -261,9 +261,9 @@ function _parse_args($args) # internal function fix_encoding($string, $silent = false) { - if (preg_match('/[\x20-\x7f][\x80-\xff][\x20-\x7f]/', $string)) + if (grapheme_strlen($string) === null) 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") !== "") + else if ($string && preg_match('/[\x80-\xff]/', $string) && grapheme_strlen(utf8_decode($string)) !== null && utf8_encode(utf8_decode($string)) === $string) list($string, $error) = array(utf8_decode($string), utf8_encode("doubly utf8-encoded: " . trim($string))); if ($error && !$silent) |