- 论坛徽章:
- 0
|
原帖由 pagx 于 2010-1-18 17:18 发表 ![]()
如果你的文件内容不是UTF-8 编码的话,需要使用下面的命令(假设文件内容是GB2312编码的):
iconv -f GB2312 -t UTF-8 /path/to/file
这类问题,通常都是编码混用的问题。我估计你的那个乱码文件是从 windows ...
-----------------------------------------------------------------------------------
谢谢
是的,我是通过FTP上传的一个txt文件。windows下记事本默认的编码(ISO-8859)。当我在windows下通过另存为编码为UTF-8,再上传到FB,这时,
$file utf8file.txt
utf8file.txt: UTF-8 Unicode (with BOM) text, with CRLF line terminators
这样一来,就可正常显示出中文内容。
$cat utf8file.txt
中文内容文本。
-----------------------------------------------------------------------------------
我们都知道file命令可以检查文件类型。
那么,这个windows下记事本默认的编码文件(ISO-8859),在FB下,如何转换成UTF-8编码的文件呢?
$iconv -l
出来的不是ISO-8859,一大堆结果。
%file asdf.txt
asdf.txt: ISO-8859 text, with no line terminators
%iconv -f ISO-8859 -t UTF-8 ~/asdf.txt > nbd
iconv: conversion from ISO-8859 unsupported
iconv: try 'iconv -l' to get the list of supported encodings
继续请教 |
|