iconv

In Unix-like operating systems, iconv (an abbreviation of internationalization conversion)[1] is a command-line program[2] and a standardized application programming interface (API)[3] used to convert between different character encodings. "It can convert from any of these encodings to any other, through Unicode conversion."[4]

iconv
Original author(s)Hewlett-Packard
Operating systemUnix and Unix-like
TypeCommand
LicenseLGPL, GPL

History

Initially appearing on the HP-UX operating system,[5]iconv() as well as the utility was standardized within XPG4 and is part of the Single UNIX Specification (SUS).

Implementations

Most Linux distributions provide an implementation, either from the GNU Standard C Library (included since version 2.1, February 1999), or the more traditional GNU libiconv, for systems based on other Standard C Libraries.

The iconv function[6] on both is licensed as LGPL, so it is linkable with closed source applications.

Unlike the libraries, the iconv utility is licensed under GPL in both implementations.[7] The GNU libiconv implementation is portable, and can be used on various UNIX-like and non-UNIX systems. Version 0.3 dates from December 1999.

The uconv utility from International Components for Unicode provides an iconv-compatible command-line syntax for transcoding.

Most BSD systems use NetBSD's implementation, first appeared in December 2004.

Support

Currently, over a hundred different character encodings are supported.[4]

Ports

Under Microsoft Windows, the iconv library and the utility is provided by GNU's libiconv found in Cygwin[8] and GnuWin32[9] environments; there is also a "purely Win32" implementation called "win-iconv" that uses Windows' built-in routines for conversion.[10] The iconv function is also available for many programming languages.

Usage

stdin can be converted from ISO-8859-1 to current locale and output to stdout using:[11]

iconv -f iso-8859-1

An input file infile can be converted from ISO-8859-1 to UTF-8 and output to output file outfile using:

iconv -f iso-8859-1 -t utf-8 <infile >outfile
gollark: ZJ?
gollark: So I think it's not actually Turing-complete but interesting at least.
gollark: <@!330678593904443393> https://squiddev.github.io/ae-sat/
gollark: ```/tmp/ignore-me: In function ‘main’:/tmp/ignore-me:10:3: error: invalid preprocessing directive #! #!/bin/sh ^/tmp/ignore-me:11:1: error: ‘TMP1’ undeclared (first use in this function) TMP1=/tmp/ignore-me ^~~~/tmp/ignore-me:11:1: note: each undeclared identifier is reported only once for each function it appears in/tmp/ignore-me:11:6: error: expected expression before ‘/’ token TMP1=/tmp/ignore-me ^/tmp/ignore-me: In function ‘main’:/tmp/ignore-me:23:3: error: invalid preprocessing directive #! #!/usr/bin/env python3 ^/tmp/ignore-me:24:1: error: unknown type name ‘import’; did you mean ‘short’? import argparse ^~~~~~ short/tmp/ignore-me:25:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘import’ import subprocess ^~~~~~/tmp/ignore-me:34:13: warning: missing terminating " character thing = f""" ^/tmp/ignore-me:34:13: error: missing terminating " character/tmp/ignore-me: In function ‘main’:/tmp/ignore-me:43:3: error: ‘code’ undeclared (first use in this function) {code} ^~~~/tmp/ignore-me:43:7: error: expected ‘;’ before ‘}’ token {code} ^ ;/tmp/ignore-me: In function ‘main’:/tmp/ignore-me:45:4: warning: missing terminating " character """ ^/tmp/ignore-me:45:4: error: missing terminating " character/tmp/ignore-me:45:4: error: expected ‘;’ before ‘return’ """ ^ ; return thing ~~~~~~/tmp/ignore-me: In function ‘main’:/tmp/ignore-me:65:1: error: unknown type name ‘iuvusugdjuczwenvxaiexhuvojlciybswpjpsqlmkkiuzxsjslkkckukhfqomqfghfonictwwbsraiffwiykmzrjspdsxkluiezu’ iuvusugdjuczwenvxaiexhuvojlciybswpjpsqlmkkiuzxsjslkkckukhfqomqfghfonictwwbsraiffwiykmzrjspdsxkluiezu ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/tmp/ignore-me:66:10: error: expected expression before ‘/’ token COMPILER=/usr/bin/gcc ^/tmp/ignore-me:71:1: error: expected declaration or statement at end of input } ^```
gollark: I'll wrap the shellscript in a shellscript which unzips it. Brilliant.

See also

References

  1. "R: Convert Character Vector between Encodings". astrostatistics.psu.edu. Retrieved 21 April 2018.
  2. "iconv". pubs.opengroup.org. Retrieved 21 April 2018.
  3. "iconv". www.opengroup.org. Retrieved 21 April 2018.
  4. "libiconv - GNU Project - Free Software Foundation (FSF)". www.gnu.org. Retrieved 21 April 2018.
  5. "iconv(3C)". docstore.mik.ua. Retrieved 21 April 2018.
  6. "glibc: iconv/iconv.c". Retrieved 30 November 2016.
  7. "glibc: iconv/iconv_prog.c". Retrieved 30 November 2016.
  8. "Cygwin Package Search: libiconv". Archived from the original on 30 November 2016. Retrieved 30 November 2016.
  9. "LibIconv for Windows". gnuwin32.sourceforge.net. Retrieved 21 April 2018.
  10. "win32-iconv". GitHub. Retrieved 30 November 2016.
  11. "IBM Knowledge Center". www-01.ibm.com. Retrieved 21 April 2018.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.