'\" te .\" Copyright 1989 AT&T .\" Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation.Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation.In the following statement, the phrase "this text" refers to portions of the system documentation.Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document.The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.This notice shall appear on any product containing this material. .TH iconv 1 "2003 年 11 月 14 日" "SunOS 5.11" "用户命令" .SH 名称 iconv \- 代码集转换实用程序 .SH 用法概要 .LP .nf \fBiconv\fR [\fB-cs\fR] \fB-f\fR \fIfrommap\fR \fB-t\fR \fItomap\fR [\fIfile\fR]... .fi .LP .nf \fBiconv\fR \fB-f\fR \fIfromcode\fR [\fB-cs\fR] [\fB-t\fR \fItocode\fR] [\fIfile\fR]... .fi .LP .nf \fBiconv\fR \fB-t\fR \fItocode\fR [\fB-cs\fR] [\fB-f\fR \fIfromcode\fR] [\fIfile\fR]... .fi .LP .nf \fBiconv\fR \fB-l\fR .fi .SH 描述 .sp .LP \fBiconv\fR 实用程序将 \fIfile\fR 中的字符或字符序列从一种代码集转换为另一种代码集,并将结果写入到标准输出。如果不存在针对某个特定字符的转换,则会为此字符执行由实现定义的转换。 .sp .LP \fBiconv\fR(5) 手册页中提供了支持的转换的列表以及关联的转换表的位置。 .SH 选项 .sp .LP 支持以下选项: .sp .ne 2 .mk .na \fB\fB-c\fR\fR .ad .RS 18n .rt 输出时忽略在输入文件的代码集中无效的字符。未使用 \fB-c\fR 时,如果在输入流中遇到了无效字符,则结果取决于转换时使用的指定代码集。无效字符可能是在输入文件的代码集中无效的字符,也可能是在输出文件的代码集中没有对应字符的字符。\fB-c\fR 存在与否不影响 \fBiconv\fR 的退出状态。为 \fB-f\fR 选项的 \fIfromcodeset\fR 指定了 \fIfromcode\fR 时,或者为 \fB-t\fR 选项的 \fItocodeset\fR 指定了 \fItocode\fR 时,可以省略 \fB-c\fR 的指定。 .RE .sp .ne 2 .mk .na \fB\fB-f\fR \fIfromcodeset\fR\fR .ad .RS 18n .rt 标识输入文件的代码集。可以识别以下两种形式的 \fIfromcodeset\fR 选项参数: .sp .ne 2 .mk .na \fB\fIfromcode\fR\fR .ad .RS 12n .rt \fIfromcode\fR 选项参数不得包含斜杠 (\fB/\fR) 字符。它被解释为用来说明某个代码集的名称。 .RE .sp .ne 2 .mk .na \fB\fIfrommap\fR\fR .ad .RS 12n .rt \fIfrommap\fR 选项参数必须包含一个斜杠字符。它被解释为 \fBcharmap\fR(5) 中定义的字符映射文件的路径名。如果路径名所表示的不是有效的可读取的字符映射文件,则会产生不确定的结果。 .RE 如果省略了此选项,则会使用当前语言环境的代码集。 .RE .sp .ne 2 .mk .na \fB\fB-l\fR\fR .ad .RS 18n .rt 将所有受支持的 \fIfromcode\fR 和 \fItocode\fR 值写入到标准输出。 .RE .sp .ne 2 .mk .na \fB\fB-s\fR\fR .ad .RS 18n .rt 抑制写入到标准错误的有关无效字符的任何消息。未使用 \fB-s\fR 时,如果在输入流中遇到了无效字符,则结果取决于转换时使用的指定代码集。无效字符可能是在输入文件的代码集中无效的字符,也可能是在输出文件的代码集中没有对应字符的字符。\fB-s\fR 存在与否不影响 \fBiconv\fR 的退出状态。为 \fB-f\fR 选项的 \fIfromcodeset\fR 指定了 \fIfromcode\fR 时,或者为 \fB-t\fR 选项的 \fItocodeset\fR 指定了 \fItocode\fR 时,可以省略 \fB-s\fR 的指定。 .RE .sp .ne 2 .mk .na \fB\fB-t\fR \fItocodeset\fR\fR .ad .RS 18n .rt 标识输出文件使用的代码集。可以识别以下两种形式的 \fItocodeset\fR 选项参数: .sp .ne 2 .mk .na \fB\fItocode\fR\fR .ad .RS 10n .rt \fItocode\fR 选项参数不得包含斜杠 (\fB/\fR) 字符。它被解释为用来说明某个代码集的名称。 .RE .sp .ne 2 .mk .na \fB\fItomap\fR\fR .ad .RS 10n .rt \fItomap\fR 选项参数必须包含一个斜杠字符。它被解释为 \fBcharmap\fR(5) 中定义的字符映射文件的路径名。如果路径名所表示的不是有效的可读取的字符映射文件,则会产生不确定的结果。 .RE 如果省略了此选项,则会使用当前语言环境的代码集。 .RE .sp .LP 如果 \fB-f\fR 和 \fB-t\fR 中有一个表示的是字符映射文件,但另一个不是,或者 \fB-f\fR 和 \fB-t\fR 有一个或者全部被省略,则 \fBiconv\fR 将失败并产生错误。 .SH 操作数 .sp .LP 支持下列操作数: .sp .ne 2 .mk .na \fB\fIfile\fR\fR .ad .RS 8n .rt 输入文件的路径名称。如果未指定 file 操作数,或者文件操作数为 "\fB-\fR",则将使用标准输入。 .RE .SH 示例 .LP \fB示例 1 \fR转换并存储文件 .sp .LP 以下示例将文件 \fBmail1\fR 的内容从代码集 \fB8859\fR 转换为 \fB646fr\fR,并将结果存储到文件 \fBmail.local\fR 中: .sp .in +2 .nf example% \fBiconv -f 8859 -t 646fr mail1 > mail.local\fR .fi .in -2 .sp .SH 环境变量 .sp .LP 有关影响 \fBiconv\fR 执行的以下环境变量的说明,请参见 \fBenviron\fR(5):\fBLANG\fR、\fBLC_ALL\fR、\fBLC_CTYPE\fR、\fBLC_MESSAGES\fR 和 \fBNLSPATH\fR。 .SH 退出状态 .sp .LP 将返回以下退出值: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 5n .rt 成功完成。 .RE .sp .ne 2 .mk .na \fB\fB1\fR\fR .ad .RS 5n .rt 出现错误。 .RE .SH 文件 .sp .ne 2 .mk .na \fB\fB/usr/lib/iconv/iconv_data\fR\fR .ad .RS 29n .rt 转换表支持的转换的列表 .RE .SH 属性 .sp .LP 有关下列属性的说明,请参见 \fBattributes\fR(5): .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型属性值 _ 可用性system/core-os _ 接口稳定性Committed(已确定) _ 标准请参见 \fBstandards\fR(5)。 .TE .SH 另请参见 .sp .LP \fBiconv\fR(3C)、\fBiconv_open\fR(3C)、\fBattributes\fR(5)、\fBcharmap\fR(5)、\fBenviron\fR(5)、\fBiconv\fR(5)、\fBiconv_unicode\fR(5)、\fBstandards\fR(5) .SH 附注 .sp .LP 确保两个字符映射文件为两个字符集中共有的字符使用相同的符号名称。 .sp .LP \fB-l\fR 选项的输出格式未指定。\fB-l\fR 选项不适用于 shell 脚本用途。 .sp .LP 为代码集转换指定了 \fIfromcode\fR 或 \fItocode\fR 时,\fBiconv\fR 会使用 \fBiconv_open\fR(3C) 函数。如果 \fBiconv_open\fR(3C) 未能打开指定的代码集转换,则 \fBiconv\fR 将搜索合适的转换表。有关 \fBiconv_open\fR(3C) 支持的代码集转换,请参考 \fBiconv\fR(5) 和 \fBiconv_locale\fR(5)。