Apache Character Set GB 2312
MySQL Character set GBK
Now to write information from MySQL (GBK) to the XML
The encoding format in XML is UTF-8
So, how to encode gbk into UTF8??
Specific introduction:
A while ago, I saw Qiushuiwuhen June's article on Gbk,unicode,big5 's conversion.
But there are a few less big problems
So I designed a class that is responsible for character conversion, fixed some of these deficiencies, added some features, and I will continue to expand the class to support more character sets
Added the following points:
Conversion of UNICODE->GBK symbol parts
Recognition of the Euro symbol
Conversion between BIG5,UNICODE,GBK, provided that only the common character set part is converted,
Instructions for use:
Temporary programs support the following character encoding methods:
Gbk,big5,utf-16be (Unicode Big-endian byte order), Utf-16le (Unicode Little-endian byte order), UTF-8
The default input encoding mode is GBK, and the default output encoding is UTF-16BE;
This category provides two functions to modify the input and output encoding methods:
Modify Input Encoding Boolean setgetencoding (String $GetEncoding)
Modify Output Encoding Boolean settoencoding (String $ToEncoding)
function parameters can only be used in the above 5 encoding methods, case-sensitive, such as GBK can not be written GBK
If the setting succeeds, returns True if the wrong encoding name is used, returns false, and the actual error message
Function
String encodestring (String $String)
Responsible for character encoding conversion, returning the converted string
Before using, convert the var $FilePath = "" Variable to the absolute path of the program file, or you will not find the data file
Example:
Converts a GBK encoded string to a UTF-8 encoding:
$s = "GBK encoding";
$CharEncoding =new Encoding ();
$CharEncoding->setgetencoding ("GBK") | | Die ("Coding name error");
$CharEncoding->settoencoding ("UTF-8") | | Die ("Coding name error");
Echo $CharEncoding->encodestring ($s);
Using UTF-8 encoding to view in the browser, you will see the correct characters