PMA_DBI_convert_message(): use $GLOBALS['charset'] as target, renamed $lang to $server_language
This commit is contained in:
@@ -27,18 +27,21 @@ function PMA_DBI_query($query, $link = NULL, $options = 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* converts charset in message, usally from mysql_error(),
|
* converts charset of a mysql message, usally coming from mysql_error(),
|
||||||
* into PMA charset, usally UTF-8
|
* into PMA charset, usally UTF-8
|
||||||
|
* uses language to charset mapping from mysql/share/errmsg.txt
|
||||||
|
* and charset names to ISO charset from information_schema.CHARACTER_SETS
|
||||||
*
|
*
|
||||||
* @uses $GLOBALS['cfg']['IconvExtraParams']
|
* @uses $GLOBALS['cfg']['IconvExtraParams']
|
||||||
* @uses PMA_DBI_fetch_value()
|
* @uses $GLOBALS['charset'] as target charset
|
||||||
* @uses preg_match()
|
* @uses PMA_DBI_fetch_value() to get server_language
|
||||||
|
* @uses preg_match() to filter server_language
|
||||||
* @uses in_array()
|
* @uses in_array()
|
||||||
* @uses function_exists()
|
* @uses function_exists() to check for a convert function
|
||||||
* @uses iconv()
|
* @uses iconv() to convert message
|
||||||
* @uses libiconv()
|
* @uses libiconv() to convert message
|
||||||
* @uses recode_string()
|
* @uses recode_string() to convert message
|
||||||
* @uses mb_convert_encoding()
|
* @uses mb_convert_encoding() to convert message
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @return string $message
|
* @return string $message
|
||||||
*/
|
*/
|
||||||
@@ -71,23 +74,26 @@ function PMA_DBI_convert_message( $message ) {
|
|||||||
'german' => 'CP1252', //'latin1',
|
'german' => 'CP1252', //'latin1',
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( $lang = PMA_DBI_fetch_value( 'SHOW VARIABLES LIKE \'language\';', 0, 1 ) ) {
|
if ( $server_language = PMA_DBI_fetch_value( 'SHOW VARIABLES LIKE \'language\';', 0, 1 ) ) {
|
||||||
if ( preg_match( '&(?:\\\|\\/)([^\\\\\/]*)(?:\\\|\\/)$&i', $lang, $found = array() ) ) {
|
if ( preg_match( '&(?:\\\|\\/)([^\\\\\/]*)(?:\\\|\\/)$&i', $server_language, $found = array() ) ) {
|
||||||
$lang = $found[1];
|
$server_language = $found[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( $lang ) && isset( $encodings[$lang] ) ) {
|
if ( ! empty( $server_language ) && isset( $encodings[$server_language] ) ) {
|
||||||
if ( function_exists( 'iconv' ) ) {
|
if ( function_exists( 'iconv' ) ) {
|
||||||
$message = iconv($encodings[$lang], 'UTF-8' . $GLOBALS['cfg']['IconvExtraParams'], $message);
|
$message = iconv( $encodings[$server_language],
|
||||||
|
$GLOBALS['charset'] . $GLOBALS['cfg']['IconvExtraParams'], $message);
|
||||||
} elseif ( function_exists( 'recode_string' ) ) {
|
} elseif ( function_exists( 'recode_string' ) ) {
|
||||||
$message = recode_string($encodings[$lang] . '..' . 'UTF-8', $message);
|
$message = recode_string( $encodings[$server_language] . '..' . $GLOBALS['charset'],
|
||||||
|
$message );
|
||||||
} elseif ( function_exists( 'libiconv' ) ) {
|
} elseif ( function_exists( 'libiconv' ) ) {
|
||||||
$message = libiconv($encodings[$lang], 'UTF-8', $message);
|
$message = libiconv( $encodings[$server_language], $GLOBALS['charset'], $message );
|
||||||
} elseif ( function_exists( 'mb_convert_encoding' ) ) {
|
} elseif ( function_exists( 'mb_convert_encoding' ) ) {
|
||||||
// do not try unsupported charsets
|
// do not try unsupported charsets
|
||||||
if ( ! in_array( $lang, array( 'ukrainian', 'greek', 'serbian' ) ) ) {
|
if ( ! in_array( $server_language, array( 'ukrainian', 'greek', 'serbian' ) ) ) {
|
||||||
$message = mb_convert_encoding( $message, 'UTF-8', $encodings[$lang] );
|
$message = mb_convert_encoding( $message, $GLOBALS['charset'],
|
||||||
|
$encodings[$server_language] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user