PHP character encoding conversion Tool _php Tutorial

Source: Internet
Author: User
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 ...

  • Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.