Re: @@@how to insert gb2312 data to utf8 table ??@@@
Posted by: Mishar
Date: November 01, 2006 11:54PM

There are many method turn gb2312 into utf8
如果数据不多就用 convertZ 转换,请叁考这网址图解说明:http://www.seed100.com/htdocs/modules/newbb/viewtopic.php?topic_id=1&forum=1

如果资料多 转换为另一种字符集很复杂 很麻烦,
但是用PHP来做却很容易,因为它里面已经包含这样的函数了,
你可以通过iconv函数很容易的来实现各种字符集之间的转化,
请叁考这网址http://seed100.com/php-mysql-101-questions/php-manual/iconv.htm
请先确认您的apache是否支持iconv,
参考phpinfo()
http://tw2.php.net/manual/tw/function.phpinfo.php
可以把以下代码 贴在notepad记事本 然后储存为phpinfo.php放在WWW(php执行区),去执行phpinfo.php就可以看到 iconv support的图表
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);
?>


如果你的机器上没有安装iconv可以到这网址http://www.gnu.org/software/libiconv/
download and read the Introduction to libiconv,
你也可以使用mb_convert_encoding函数
<?php
$s = "從「gb2312」轉換成「UTF-8」\n";
$a = array("將陣列所有元素", "一起從「gb2312」", "轉換成「UTF-8」\n");

header("Content-Type: text/plain; charset=UTF-8");
echo "[mb_convert_encoding]\n";
echo mb_convert_encoding($s, "UTF-8", "gb2312") . "\n";

echo "[mb_convert_variables]\n";
mb_convert_variables("UTF-8", "gb2312", $a);
echo implode("", $a);
?>



Edited 2 time(s). Last edit at 11/08/2006 10:12AM by Mishar .

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: @@@how to insert gb2312 data to utf8 table ??@@@
4466
November 01, 2006 11:54PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.