diff options
author | Michal Čihař <michal@cihar.com> | 2004-04-29 13:28:04 +0400 |
---|---|---|
committer | Michal Čihař <michal@cihar.com> | 2004-04-29 13:28:04 +0400 |
commit | cfbdb563d0666b4a9f7abf97e867391e76534901 (patch) | |
tree | bc137b0dcb9997d7d7bcdb885262315a4b9e340c /libraries/string.lib.php | |
parent | 51fc2da513ab549e3aae9026975aee13ee509c17 (diff) |
SQL parser now correctly works with multibyte strings (bug #936161).
Diffstat (limited to 'libraries/string.lib.php')
-rw-r--r-- | libraries/string.lib.php | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/libraries/string.lib.php b/libraries/string.lib.php index 13fc42f28c..bedb9defc5 100644 --- a/libraries/string.lib.php +++ b/libraries/string.lib.php @@ -14,9 +14,14 @@ * * The SQL Parser code relies heavily on these functions. */ + +$GLOBALS['PMA_allow_mbstr'] = @function_exists('mb_strlen') && substr($GLOBALS['charset'], 0, 8) != 'windows-'; +if ($GLOBALS['PMA_allow_mbstr']) { + mb_internal_encoding($GLOBALS['charset']); +} // This is for handling input better -if (defined('PMA_MULTIBYTE_ENCODING')) { +if (defined('PMA_MULTIBYTE_ENCODING') || $GLOBALS['PMA_allow_mbstr']) { $GLOBALS['PMA_strpos'] = 'mb_strpos'; $GLOBALS['PMA_strrpos'] = 'mb_strrpos'; } else { @@ -24,8 +29,6 @@ if (defined('PMA_MULTIBYTE_ENCODING')) { $GLOBALS['PMA_strrpos'] = 'strrpos'; } -$GLOBALS['PMA_has_mbstr'] = @function_exists('mb_strlen'); - /** * Returns length of string depending on current charset. * @@ -39,11 +42,9 @@ $GLOBALS['PMA_has_mbstr'] = @function_exists('mb_strlen'); */ function PMA_strlen($string) { - if (defined('PMA_MULTIBYTE_ENCODING')) { - return mb_strlen($string); // windows-* charsets are not multibyte and not supported by mb_* - } elseif($GLOBALS['PMA_has_mbstr'] && substr($GLOBALS['charset'],0,8) != 'windows-') { - return mb_strlen($string, $GLOBALS['charset']); + if (defined('PMA_MULTIBYTE_ENCODING') || $GLOBALS['PMA_allow_mbstr']) { + return mb_strlen($string); } else { return strlen($string); } @@ -56,7 +57,7 @@ function PMA_strlen($string) * @param int start of substring * @param int length of substring * - * @return int string length + * @return int substring * * @access public * @@ -64,10 +65,8 @@ function PMA_strlen($string) */ function PMA_substr($string, $start, $length = 2147483647) { - if (defined('PMA_MULTIBYTE_ENCODING')) { + if (defined('PMA_MULTIBYTE_ENCODING') || $GLOBALS['PMA_allow_mbstr']) { return mb_substr($string, $start, $length); - } elseif($GLOBALS['PMA_has_mbstr'] && substr($GLOBALS['charset'],0,8) != 'windows-') { - return mb_substr($string, $start, $length, $GLOBALS['charset']); } else { return substr($string, $start, $length); } |