Various Chinese encoding conversion classes implemented by PHP _ javascript tips-js tutorial

Source: Internet
Author: User
This article mainly introduces the PHP implementation of various Chinese encoding conversion class sharing, this class library supports the conversion between Simplified Chinese, traditional Chinese, GB2312, BIG5, UTF-8 and other formats, you can refer to the current class libraries for encoding conversion: Simplified Chinese GB <-> traditional Chinese BIG5 encoding interchange, simple/Traditional Chinese-> pinyin one-way conversion, simplified/Traditional Chinese <-> UTF8 encoding conversion, simplified/Traditional Chinese-> Unicode one-way conversion.

The original author of the class source code is Hessian (solarischan@21cn.com), I merged the original Sample script, and modified the class file, add a parameter to the class constructor so that you can easily set the configuration file path when using it. In this way, you can place this class package in any directory that can be accessed, otherwise, the original version references class. chinese. php files and classes must be in the same directory.

The Code is as follows:


/**
* Chinese encoding set class library
*
* Currently, this class library can be used for conversion between Simplified Chinese and Traditional Chinese <-> traditional Chinese encoding, simplified Chinese and Traditional Chinese-> pinyin one-way conversion,
* Simplified Chinese and Traditional Chinese <-> UTF8 encoding conversion, simplified Chinese and Traditional Chinese-> Unicode one-way conversion
*
* @ Author Hessian (solarischan@21cn.com)
* @ Version 1.7
* @ Copyright: Hessian/NETiS
* @ Use authorized GPL (the Code cannot be used for any commercial purposes and can be modified without the author's consent, but the modified Code must be published in accordance with the GPL Protocol)
* @ Special thanks to unknow (simplified conversion code snippet)
* @ Start
* @ Last modification
* @ Access public
*
* Update records
*
* Ver 1.7
* The bug caused by the while loop is modified. This bug will handle errors when the last character of the string is "0.
* Affected Methods: CHStoUTF8 (), CHStoUNICODE ()
* (By Zeal Li, http://www.zeali.net /)
*
* Ver 1.6
* The constructor adds a parameter so that you can conveniently set the configuration file path when using it.
* (By Zeal Li, http://www.zeali.net /)
*
* Ver 1.5
* Added the UTF8 Conversion Function to GB2312 and BIG5.
*
* Ver 1.4
* The value of charset can be changed if the value is set to true When HTML is converted.
*
* Ver 1.3
* The function of converting traditional Chinese to Pinyin is added.
*
* Ver 1.2
* Merge functions that convert simplified and Traditional Chinese to UTF8.
* The function for converting Simplified Chinese to pinyin. the return value is changed to a string. the Pinyin of each Chinese character is separated by spaces.
* Supports converting Simplified Chinese to UNICODE.
* The function of converting traditional Chinese to UNICODE is added.
*
* Ver 1.1
* Added the OpenFile () function to support opening local files and remote files.
* Added the function of converting Simplified Chinese to UTF8.
* The function of converting traditional Chinese to UTF8 is added.
*
* Ver 1.0
* A Class Library integrating simplified Chinese characters and traditional Chinese characters corresponding to various encoding interchange has been initially completed.
*/


Download the full source code package (filesize: 132,522 bytes): Download the source code chinese.rar
Related Article

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.