How to transcode Chinese characters in php

王林
Release: 2023-03-06 16:24:02
Original
6308 people have browsed it

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);
Copy after login

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);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template