批量转换cp1252到utf-8在Windows [英] Bulk convert cp1252 to utf-8 in Windows

查看:746
本文介绍了批量转换cp1252到utf-8在Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,
我一直在试图将一个大的java源代码树从cp1252转换为UTF-8在Windows中,使用提示和trix我发现在线,特别是在这里。问题是,我在Windows上;我不做VB; Cygwin的iconv不采取 -o 切换。

So, I've been trying to convert a large java source tree from cp1252 to UTF-8 in Windows, using tips and trix I've found online, specificly here. Problem is, I'm on Windows; I don't do VB; Cygwin's iconv doesn't take the -o switch.

我第一次尝试使用的行是:

The line I first tried to use is:

find . -type f -print -exec iconv -f cp1252 -t utf-8 {} > {}.converted \; -exec mv {}.converted {} \;

这会创建一个文件 {}。convert 在工作目录中,而第二个 -exec 由于显而易见的原因失败。

This creates a file {}.converted in the working directory and the second -exec fails for obvious reasons.

/ p>

Putting quotes around the iconv expression:

find . -type f -print -exec 'iconv -f cp1252 -t utf-8 {} > {}.converted' \; -exec mv {}.converted {} \;

resulsts在下列错误中:

resulsts in the folowing error:

find: `iconv -f cp1252 -t utf-8 ./java/dv/framework/activity/model/ActivitiesMediaViewImpl.java > ./java/dv/framework/activity/model/ActivitiesMediaViewImpl.java.converted': No such file or directory



though executing the individual expressions by hand works perfectly.

我已经尝试了随机引用,但没有什么似乎工作,我错过了什么?为什么不工作..

I've experimented with random quoting but nothing seems to work, what am I missing? Why won't it work..?

Thanx提前,
Lars

Thanx in advance, Lars

推荐答案

for f in `find . -type f`; do
    iconv -f cp1252 -t utf-8 $f > $f.converted
    mv $f.converted $f
done

这篇关于批量转换cp1252到utf-8在Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆