我有一台运行Debian stable的旧电脑,需要升级。 问题在于它使用的是latin1(ISO-8859-1),而且由于世界其他地方已经转移到了UTF-8,所以我也计划转换这台计算机。
对于这个问题,我将重点介绍Samba提供的文件,还有一些在文件名中有一些latin1字符(如åäö)。
现在我的计划是将这台旧计算机的所有数据移到一个运行Debian稳定(但使用UTF-8)的全新数据上。
有人有一个好主意吗?
注意 :稍后我打算使用iconv来转换一些文件的内容,如下所示:
iconv --from-code=ISO-8859-1 --to-code=UTF-8 iso.txt > utf.txt
但是,我不知道一个好的方法来转换自己的文件系统。
注意 :通常我只是从一台电脑到另一台电脑的scp ,但是最后我在utf-8文件系统中input了latin1字符。
更新 :在文件名中用一手文件(有趣的字符)做了一个小testing,看起来好像可以工作。
convmv -r -f ISO-8859-1 -t UTF-8 *
注意 : -r =recursion; -f / -t =从/到。
所以只能用--notest来执行
convmv -r -f ISO-8859-1 -t UTF-8 --notest *
没有更多的。
使用convmv:
Package: convmv Priority: optional Section: utils Installed-Size: 88 Maintainer: Raphael Zimmerer <[email protected]> Architecture: all Version: 1.12-1 Depends: perl Filename: pool/main/c/convmv/convmv_1.12-1_all.deb Size: 20052 MD5sum: dcc45d5b8517026f588d769d81d67768 SHA1: 55da9650cfee5c64d8a4fdf278aaf9401a5e5dec SHA256: 0a8b0165a78dc42f7dc665a14d21c22ce0433d115fe537be2af74682d3b82a5f Description: filename encoding conversion tool convmv can convert a single filename, a directory tree or all files on a filesystem to a different encoding. It only converts the encoding of filenames, not files contents. A special feature of convmv is that it also takes care of symlinks: the encoding of the symlink's target will be converted if the symlink itself is being converted. . It is also possible to convert directories to UTF-8 which are already partially UTF-8 encoded. . Keywords: rename, move Tag: devel::i18n, implemented-in::perl, interface::commandline, role::program, scope::utility, works-with::file
apt-get install convmv
🙂
请注意,在他们传输文件之前遇到此页面的读者:
您可以使用最近的rsync和–iconv选项进行传输:
rsync -va --iconv=utf8,iso88591 /source/latin1/ /destination/utf8
(是的,iconv字符集的sorting不直观!)
因为转移已经完成,确实convmv是解决scheme。
有一个Unicode字符编码转换器支持Unicode(UTF-8 / UTF-16 / UTF-7 / UTF-32)和非Unicode(Ansi,中文简体GBK,中文传统BIG5,日文SHIFT-JIS,日语EUC-JP,韩语euc-kr字符集编码等)。
在当前目录中执行此操作:
for f in `ls`; do iconv --from-code=iso-8859-1 --to-code=utf-8 $f -o $f; done
如果这个文件不在目标编码范围内,我会先testing一下,否则你可能会搞乱你的文件。 (下面的例子zsh),你可以调整代码并将其放在“for”循环中。
codification="`file -bi "$1" | awk -F"=" '{print $NF}'`" [[ "$codification" != "utf-8" ]] && iconv -f ISO8859-1 -t UTF-8 "$1" > $outfile