本文整理汇总了PHP中PMA_aix_iconv_wrapper函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_aix_iconv_wrapper函数的具体用法?PHP PMA_aix_iconv_wrapper怎么用?PHP PMA_aix_iconv_wrapper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_aix_iconv_wrapper函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_DBI_convert_message
/**
* converts charset of a mysql message, usually coming from mysql_error(),
* 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['charset'] as target charset
* @uses PMA_DBI_fetch_value() to get server_language
* @uses preg_match() to filter server_language
* @uses in_array()
* @uses function_exists() to check for a convert function
* @uses iconv() to convert message
* @uses libiconv() to convert message
* @uses recode_string() to convert message
* @uses mb_convert_encoding() to convert message
* @param string $message
* @return string $message
*/
function PMA_DBI_convert_message($message)
{
// latin always last!
$encodings = array('japanese' => 'EUC-JP', 'japanese-sjis' => 'Shift-JIS', 'korean' => 'EUC-KR', 'russian' => 'KOI8-R', 'ukrainian' => 'KOI8-U', 'greek' => 'ISO-8859-7', 'serbian' => 'CP1250', 'estonian' => 'ISO-8859-13', 'slovak' => 'ISO-8859-2', 'czech' => 'ISO-8859-2', 'hungarian' => 'ISO-8859-2', 'polish' => 'ISO-8859-2', 'romanian' => 'ISO-8859-2', 'spanish' => 'CP1252', 'swedish' => 'CP1252', 'italian' => 'CP1252', 'norwegian-ny' => 'CP1252', 'norwegian' => 'CP1252', 'portuguese' => 'CP1252', 'danish' => 'CP1252', 'dutch' => 'CP1252', 'english' => 'CP1252', 'french' => 'CP1252', 'german' => 'CP1252');
if ($server_language = PMA_DBI_fetch_value('SHOW VARIABLES LIKE \'language\';', 0, 1)) {
$found = array();
if (preg_match('&(?:\\\\|\\/)([^\\\\\\/]*)(?:\\\\|\\/)$&i', $server_language, $found)) {
$server_language = $found[1];
}
}
if (!empty($server_language) && isset($encodings[$server_language])) {
if (function_exists('iconv')) {
if (@stristr(PHP_OS, 'AIX') && @strcasecmp(ICONV_IMPL, 'unknown') == 0 && @strcasecmp(ICONV_VERSION, 'unknown') == 0) {
require_once './libraries/iconv_wrapper.lib.php';
$message = PMA_aix_iconv_wrapper($encodings[$server_language], $GLOBALS['charset'] . $GLOBALS['cfg']['IconvExtraParams'], $message);
} else {
$message = iconv($encodings[$server_language], $GLOBALS['charset'] . $GLOBALS['cfg']['IconvExtraParams'], $message);
}
} elseif (function_exists('recode_string')) {
$message = recode_string($encodings[$server_language] . '..' . $GLOBALS['charset'], $message);
} elseif (function_exists('libiconv')) {
$message = libiconv($encodings[$server_language], $GLOBALS['charset'], $message);
} elseif (function_exists('mb_convert_encoding')) {
// do not try unsupported charsets
if (!in_array($server_language, array('ukrainian', 'greek', 'serbian'))) {
$message = mb_convert_encoding($message, $GLOBALS['charset'], $encodings[$server_language]);
}
}
} else {
/**
* @todo lang not found, try all, what TODO ?
*/
}
return $message;
}
示例2: PMA_convert_file
/**
* Converts encoding of file according to parameters with detected
* conversion function. The old file will be unlinked and new created and
* its file name is returned.
*
* @param string source charset
* @param string target charset
* @param string file to convert
*
* @return string new temporay file
*
* @access public
*
* @author nijel
*/
function PMA_convert_file($src_charset, $dest_charset, $file)
{
switch ($GLOBALS['PMA_recoding_engine']) {
case PMA_CHARSET_RECODE:
case PMA_CHARSET_ICONV:
case PMA_CHARSET_LIBICONV:
$tmpfname = tempnam('', 'PMA_convert_file');
$fin = fopen($file, 'r');
$fout = fopen($tmpfname, 'w');
if ($GLOBALS['PMA_recoding_engine'] == PMA_CHARSET_RECODE) {
recode_file($src_charset . '..' . $dest_charset, $fin, $fout);
} else {
while (!feof($fin)) {
$line = fgets($fin, 4096);
if ($GLOBALS['PMA_recoding_engine'] == PMA_CHARSET_ICONV) {
$dist = iconv($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $line);
} elseif ($GLOBALS['PMA_recoding_engine'] == PMA_CHARSET_ICONV_AIX) {
$dist = PMA_aix_iconv_wrapper($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $line);
} else {
$dist = libiconv($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $line);
}
fputs($fout, $dist);
}
// end while
}
fclose($fin);
fclose($fout);
unlink($file);
return $tmpfname;
default:
return $file;
}
}