将整个项目的字符集转换为 utf-8 [英] Convert charset from a entire project to utf-8
问题描述
我有一个在 windows 中制作的项目,它使用 windows 1252 字符集,我需要将所有 .php 文件转换为 utf-8 字符集,因为我的数据库都是 utf-8 编码的.有没有办法使用 linux 命令或软件来做到这一点?
在你项目的根目录中,使用 find(1) 列出所有 *.php
文件并将其与 recode(1) 就地转换这些文件:
查找.-type f -name '*.php' -exec recode windows1252..utf8 \{} \;
作为 recode(1) 的替代方法,您还可以使用 iconv(1) 进行转换(用于上述 find
命令:iconv -f windows-1252 -t utf-8 -o \{} \{}
).>
您需要安装 recode 或 iconv 才能使上述工作正常运行.两者都应该可以通过大多数现代系统上的包管理器轻松安装.
Hi i have a project made in windows who uses windows 1252 charset and i need to convert all my .php file to utf-8 charset because my database is all utf-8 encoded. Is there a way to do that using linux commands or a software?
In your project's root directory, use find(1) to list all *.php
files and combine that with recode(1) to convert those files in place:
find . -type f -name '*.php' -exec recode windows1252..utf8 \{} \;
As an alternative to recode(1), you could also use iconv(1) to do the conversion (for usage with above find
command: iconv -f windows-1252 -t utf-8 -o \{} \{}
).
You need to have either recode or iconv installed for the above to work. Both should be easily installable via a package manager on most modern systems.
这篇关于将整个项目的字符集转换为 utf-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!