Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教一下python那个问题 #1

Open
liuubowei opened this issue Sep 17, 2018 · 2 comments
Open

请教一下python那个问题 #1

liuubowei opened this issue Sep 17, 2018 · 2 comments

Comments

@liuubowei
Copy link

我在运行第一次的时候,程序遍历了所有文件并转化,但是第二次还是打印转换,这样的话格式并没有转换啊

@jianboy
Copy link
Owner

jianboy commented Sep 17, 2018

本项目提供java php python等多种编程语言的实现。如果你习惯用java。打开https://github.com/jianboy/gbk2utf8/blob/master/java/convert.java文件,修改srcDirPath路径等就可以了运行了。

实现原理很简单,即遍历所在文件夹所有文件,GBK读取每个文件,然后以UTF-8写入:

FileUtils.writeLines(new File(utf8FilePath), "UTF-8", FileUtils.readLines(javaGbkFile, "GBK"));

php也是类似的道理:

rename($dir."/".$file,$dir."/".mb_convert_encoding($file,"GBK", "UTF-8"));

@jianboy
Copy link
Owner

jianboy commented Sep 17, 2018

由于你描述比较模糊,不能具体定位你的问题。如果还有问题,请贴上你的某单个文件。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants