A while ago, I saw Qiushuiwuhen's article about the conversion of GBK,UNICODE,BIG5.
But there are a few things that are not too big.
So I designed a class that is responsible for character conversion, fixed some of the shortcomings, added some features, I will continue to expand the class, to support more character sets
The following points are added:
UNICODE->GBK Conversion of symbol parts
Recognition of the euro symbol (€)
Conversions between BIG5,UNICODE,GBK, provided that only the common character set part is converted,
Instructions for use:
The following character encodings are supported by the temporary program:
Gbk,big5,utf-16be (Unicode Big-endian byte order), Utf-16le (Unicode Little-endian byte order), UTF-8
The default input encoding method is GBK, the default output encoding is UTF-16BE;
This category provides two functions to modify the input and output encoding methods:
Modifying the input encoding method, Boolean setgetencoding (String $GetEncoding)
Modify output encoding by 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, the var $FilePath = "" Variable is the absolute path of the program file, otherwise the data file will not be found
Example:
Convert the GBK encoded string to UTF-8 encoding:
$s = "GBK code";
$CharEncoding =new Encoding ();
$CharEncoding->setgetencoding ("GBK") | | Die ("Wrong coding name");
$CharEncoding->settoencoding ("UTF-8") | | Die ("Wrong coding name");
Echo $CharEncoding->encodestring ($s);
Using UTF-8 encoding in your browser, you will see the correct characters
Program Download Address:
Http://dreamcity2000.myetang.com/encoding.zip
When downloading, please reopen a browser window and enter the address above to download.
PS: If the program is to be reproduced, please contact the author
http://www.bkjia.com/PHPjc/445220.html www.bkjia.com true http://www.bkjia.com/PHPjc/445220.html techarticle A while ago, I saw Qiushuiwuhen's article about the conversion of GBK,UNICODE,BIG5. But how many of them are not too big? So I designed a class that is responsible for character conversion, fixed the ...