php的字符编码转换工具_PHP
前一阵子见到了qiushuiwuhen君的关于gbk,unicode,big5的转换的文章
但是多少有一些不太大的问题
于是我设计了一个负责字符转换的类,修正了其中的一些不足,增加了部分功能,以后我会不断扩充该类,来支持更多的字符集
增加了如下几点:
unicode->gbk 符号部分的转换
欧元符(€)的识别
big5,Unicode,GBK之间的相互转换,前提是只转换共同的字符集部分,
使用说明:
暂时程序支持以下字符编码方式:
GBK,BIG5,UTF-16BE(Unicode big-endian字节顺序),UTF-16LE(Unicode little-endian字节顺序),UTF-8
默认输入编码方式为GBK,默认输出编码方式为UTF-16BE;
该类别提供两个函数用来修改输入和输出编码方式:
修改输入编码方式 boolean SetGetEncoding(string $GetEncoding)
修改输出编码方式 boolean SetToEncoding(string $ToEncoding)
函数参数只能使用上述5种编码方式,区分大小写,如GBK不能写成gbk
如果设置成功,返回true,如果使用了错误的编码名,返回false,并现实错误信息
函数
string EncodeString(string $String)
负责进行字符编码转换,返回转换后的字符串
使用前,请将var $FilePath=""变量该为该程序文件的绝对路径,否则将会找不到数据文件
例子:
将gbk编码的字符串转化为UTF-8编码:
$s="GBK编码";
$CharEncoding=new Encoding();
$CharEncoding->SetGetEncoding("GBK")||die("编码名错误");
$CharEncoding->SetToEncoding("UTF-8")||die("编码名错误");
echo $CharEncoding->EncodeString($s);
在浏览器中使用UTF-8编码察看,将会看到正确的字符
程序下载地址:
http://dreamcity2000.myetang.com/encoding.zip
下载时请重新打开一个浏览器窗口然后输入上面的地址才能下载.
ps:程序如要转载,请和作者联系

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The main differences between Laravel and Yii are design concepts, functional characteristics and usage scenarios. 1.Laravel focuses on the simplicity and pleasure of development, and provides rich functions such as EloquentORM and Artisan tools, suitable for rapid development and beginners. 2.Yii emphasizes performance and efficiency, is suitable for high-load applications, and provides efficient ActiveRecord and cache systems, but has a steep learning curve.

To safely and thoroughly uninstall MySQL and clean all residual files, follow the following steps: 1. Stop MySQL service; 2. Uninstall MySQL packages; 3. Clean configuration files and data directories; 4. Verify that the uninstallation is thorough.

With the popularization and development of digital currency, more and more people are beginning to pay attention to and use digital currency apps. These applications provide users with a convenient way to manage and trade digital assets. So, what kind of software is a digital currency app? Let us have an in-depth understanding and take stock of the top ten digital currency apps in the world.

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

The built-in quantization tools on the exchange include: 1. Binance: Provides Binance Futures quantitative module, low handling fees, and supports AI-assisted transactions. 2. OKX (Ouyi): Supports multi-account management and intelligent order routing, and provides institutional-level risk control. The independent quantitative strategy platforms include: 3. 3Commas: drag-and-drop strategy generator, suitable for multi-platform hedging arbitrage. 4. Quadency: Professional-level algorithm strategy library, supporting customized risk thresholds. 5. Pionex: Built-in 16 preset strategy, low transaction fee. Vertical domain tools include: 6. Cryptohopper: cloud-based quantitative platform, supporting 150 technical indicators. 7. Bitsgap:

Renaming a database in MySQL requires indirect methods. The steps are as follows: 1. Create a new database; 2. Use mysqldump to export the old database; 3. Import the data into the new database; 4. Delete the old database.

Integrating Sentry and Bugsnag in Laravel can improve application stability and performance. 1. Add SentrySDK in composer.json. 2. Add Sentry service provider in config/app.php. 3. Configure SentryDSN in the .env file. 4. Add Sentry error report in App\Exceptions\Handler.php. 5. Use Sentry to catch and report exceptions and add additional context information. 6. Add Bugsnag error report in App\Exceptions\Handler.php. 7. Use Bugsnag monitoring
