Home >Web Front-end >JS Tutorial >Sharing of various Chinese encoding conversion classes implemented in PHP_javascript skills

Sharing of various Chinese encoding conversion classes implemented in PHP_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:18:17999browse

Currently, the encoding conversions that this class library can implement include: Simplified Chinese GB <-> Traditional Chinese BIG5 encoding interchange, Simplified/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, modified the class file, and added a parameter to the class constructor so that users can use it conveniently. When setting the configuration file path, this class package can be placed in any directory that can be accessed. Otherwise, the file referencing class.Chinese.php in the original version must be in the same directory as the class.

Copy code The code is as follows:

/**
* Chinese coding collection class library
*
* Currently this class library can implement, Simplified Chinese <-> Traditional Chinese encoding interchange, Simplified Chinese, Traditional Chinese -> Pinyin one-way conversion,
* Simplified Chinese, Traditional Chinese <-> UTF8 encoding conversion, Simplified Chinese, Traditional Chinese -> Unicode one-way conversion
*
* @author Hessian(solarischan@21cn.com)
* @Version 1.7
* @Copyright Hessian / NETiS
* @Use Authorization GPL (cannot be used for any commercial purposes, the code can be modified without the author's consent, but the modified code must be released in accordance with the GPL agreement)
* @Special thanks unknow (Traditional-Simplified conversion code snippet)
* @start 2003-04-01
* @Last modified 2005-07-26
* @visit Public
*
* Update record
*
* ver 1.7 2005-07-26
* Modified the bug caused by while loop. 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 2005-05-16
* The constructor adds a parameter so that users can easily set the configuration file path when using it
* (by Zeal Li ,http://www.zeali.net/)
*
* ver 1.5 2003-06-06
* Add the function of converting UTF8 to GB2312 and BIG5.
*
* ver 1.4 2003-04-07
* Added: When converting HTML, set it to true to change the value of charset.
*
* ver 1.3 2003-04-02
* Added the function of converting Traditional Chinese to Pinyin.
*
* ver 1.2 2003-04-02
* Merge functions to convert Simplified and Traditional Chinese to UTF8.
* Modify the function that converts Simplified Chinese to Pinyin, the return value is changed to a string, and the Pinyin of each Chinese character is separated by spaces
* Added the function of converting Simplified Chinese to UNICODE.
* Added the function of converting Traditional Chinese to UNICODE.
*
* ver 1.1 2003-04-02
* Added OpenFile() function to support opening local files and remote files.
* Added the function of converting Simplified Chinese to UTF8.
* Added the function of converting Traditional Chinese to UTF8.
*
* ver 1.0 2003-04-01
* A class library that integrates simplified Chinese and traditional Chinese corresponding to various coding interchanges has been initially completed.
​*/

Download the complete source code package (filesize: 132,522 bytes): Download source code chinese.rar
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn