Home  >  Article  >  Backend Development  >  How to transcode Chinese characters in php

How to transcode Chinese characters in php

王林
王林Original
2020-10-12 10:20:296256browse

php method for transcoding Chinese characters: [$fileName=iconv("UTF-8", "gbk", $fileName);], which means conversion to the Chinese encoding format of gbk.

How to transcode Chinese characters in php

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!

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