Coding <?php
/**
* This procedure is used to load the simplified code from the coding table and to shorten the loading time by serialization
* also provides two simplified conversion functions
* Use method:
* Add in the required program
* require_once "load_gb_big5.php";
* SetChar (["Big5"]);
*/
$filename = "Gb_big5.txt";
if (!file_exists ($filename)) {
/**
* Connect and open the comparison table
*/
$conn = mysql_connect ();
mysql_select_db ("Unicode");
/**
* Extract Big5 and GBK encoded in the table with only 13,487 Big5 (including symbols)
*/
$sql = "Select gbk,big5,gb2312 from Unicode where Big5!= '";
$rs = mysql_query ($sql);
/**
* Read the data to the array, pay attention to the key and value processing
*/
$code = Array (0=> "Big5", gb2312=>0);
/**
* Set conversion type and lose out
* There is no other output before this function
*/
function SetChar ($char = "gb2312") {
Global $code;
if ($char!= "gb2312" && $char!= "Big5")
Die ("character encoding type wrong!!!");
if ($code [0]!= $char)
$code = Array_flip ($code); Exchange key if not the specified encoding type
Header ("content-type:text/html; charset= $char ");
}
?>
Test Example:
<?php
Require_once "load_gb_big5.php";
SetChar ("Big5");
Echo GetChar ('
Recently completed the GBK, gb2312, Big5 coding comparison table (including its Hanyu Pinyin) collation
Now in a text file to provide to you, compression package 297k
Where: (all include symbols)
GBK 21791
Big5 15863
gb2312 7478
Note that the data row "," must be under MySQL, or it may be wrong. Some friends get the new version may not, please add.
(2002-10-24)
Interested friends please contact me, email:czjsz_ah@stats.gov.cn
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.