【高分求助】linux系统下本地语言编码转utf8。

afgkidy 2013-12-18 09:06:39
某个文件内容可能是中文、英文、或其他语言,采用不同编码方式。
请问用什么办法可以把他们都转换成utf8格式?
file -i filename 可以查到字符集,能否根据这个信息转换?

注:用户态程序C语言
...全文
121 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
SweetTimeRose 2013-12-18
  • 打赏
  • 举报
回复
学习下
heartlesstoanyone 2013-12-18
  • 打赏
  • 举报
回复
#include <iconv.h> size_t iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
heartlesstoanyone 2013-12-18
  • 打赏
  • 举报
回复
ICONV(1) ICONV(1) NAME iconv - Convert encoding of given files from one encoding to another SYNOPSIS iconv -f encoding -t encoding inputfile DESCRIPTION The iconv program converts the encoding of characters in inputfile from one coded character set to another. The result is written to standard output unless otherwise specified by the --output option. --from-code, -f encoding Convert characters from encoding --to-code, -t encoding Convert characters to encoding --list List known coded character sets --output, -o file Specify output file (instead of stdout) --verbose Print progress information. EXAMPLES Following examples convert from code set ISO88592 "input.txt" to UTF8 code set or ASCII and stores the result as "output.txt". iconv -f ISO88592 -t UTF8 < input.txt > output.txt iconv -f ISO88592 -t ASCII//TRANSLIT < input.txt > output.txt AUTHOR iconv is written by Ulrich Drepper as part of the GNU C Library. This man page is written by Joel Klecker <espy@debian.org>, for the Debian GNU/Linux system. 3rd Berkeley Distribution March 2001 ICONV(1)

23,217

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧