Home >Backend Development >PHP Problem >How to transcode Chinese characters in php
php method for transcoding Chinese characters: [$fileName=iconv("UTF-8", "gbk", $fileName);], which means conversion to the Chinese encoding format of gbk.
Usually when uploading files in PHP, if the file name contains Chinese characters, the uploaded name cannot be written locally because the uploaded encoding format is normal. It is in UTF-8 format. This format cannot name the file and store it on the operating system disk.
(Recommended tutorial: php video tutorial)
You need to convert it to the Chinese encoding format of gbk before writing:
$fileName=iconv("UTF-8", "gbk", $fileName);
Similarly, The file name obtained by reading the file from the system disk is in gbk encoding format. This format cannot be passed to other pages by PHP. At this time, it needs to be encoded into UTF-8 format
$fileName=iconv("gbk", "UTF-8", $fileName);
Related recommendations: php training
The above is the detailed content of How to transcode Chinese characters in php. For more information, please follow other related articles on the PHP Chinese website!