iconv[1]是一个计算机程序[2]以及一套应用程序编程接口[3]的名称。它的作用是在多种国际编码格式之间进行文本内码的转换。支持的内码包括:
- Unicode相关编码,如UTF-8、UTF-16等等
- 各国采用的ANSI编码,其中包括GB2312、BIG5等中文编码方式。
作为应用程序的iconv采用命令行界面,允许将某种特定编码的文件转换为另一种编码。
用法
文件infile
从GB18030编码转换至UTF-8编码并写入到文件outfile
中:
iconv -f GB18030 -t utf-8 < infile > outfile
PHP(页面存档备份,存于互联网档案馆)语言对iconv封装了3个函数:
- iconv_open函数用于初始化用于转换的内部缓冲区,需要指明需要从何种编码方式转换到哪一种。
- iconv函数进行实际的转换,需要给出两个间接缓冲区指针和剩余字节数指针。该函数需要更新所有相关信息,因此将不可改写的指针传递给iconv是错误的。
- iconv_close函数释放iconv_open函数的缓冲区。
iconv基于GPL公开源代码,是GNU项目的一部分。在各种UNIX操作系统下均可使用,而在Windows系统,需要特殊的环境如cygwin或者GnuWin32等软件平台下方可使用。现在在SourceForge上也有运行于Windows系统的,需要同时安装gettext程序。
目前,libiconv已经包含在C运行时刻库libc.so
中。因此,Linux平台上使用iconv库函数的程序,需要包含<iconv.h>,但链接时不需要引入libiconv库了。
参考文献
- ^ R: Convert Character Vector between Encodings. astrostatistics.psu.edu. [21 April 2018]. (原始内容存档于2020-10-31).
- ^ iconv. pubs.opengroup.org. [21 April 2018]. (原始内容存档于2020-10-28).
- ^ iconv. www.opengroup.org. [21 April 2018]. (原始内容存档于2010-12-08).
外部链接
- http://gettext.sourceforge.net/(页面存档备份,存于互联网档案馆)
|
---|
| 文件系統 | - cat
- cd
- chmod
- chown
- chgrp
- cksum
- cmp
- cp
- dd
- du
- df
- file
- fsck
- fuser
- ln
- ls
- mkdir
- mount
- mv
- pax(英语:pax (Unix))
- pwd
- rm
- rmdir
- size
- split
- stat
- tee
- touch
- type(英语:type (Unix))
- umask(英语:umask)
|
---|
| 程序 | - at
- bg
- chroot
- cron
- fg
- kill
- killall(英语:killall)
- nice
- pgrep
- pkill(英语:pkill)
- ps
- pstree(英语:pstree)
- time
- top
|
---|
| 用户环境 | |
---|
| 文本编辑 | - awk
- banner(英语:banner (Unix))
- basename
- comm(英语:comm)
- csplit(英语:csplit)
- cut
- diff
- dirname
- ed
- ex
- fmt(英语:fmt)
- fold(英语:fold (Unix))
- head(英语:head (Unix))
- iconv
- join(英语:join (Unix))
- less
- more
- nl(英语:nl (Unix))
- paste(英语:paste (Unix))
- sed
- sort(英语:sort (Unix))
- spell(英语:spell (Unix))
- strings(英语:strings (Unix))
- tail
- tr
- uniq(英语:uniq)
- vi
- wc
- xargs
|
---|
| 壳层内建 | |
---|
| 网络 | |
---|
| 查找 | |
---|
| 文档 | - apropos(英语:apropos (Unix))
- help(英语:help (command))
- man
|
---|
| 软件开发 | |
---|
| 杂项 | - bc
- cal
- dc
- expr
- lp(英语:lp (Unix))
- lpr
- sleep
- true和false
- yes
|
---|
| |
|