uconv command: convert encoding of character set
Syntax
uconv [-f FromCode] [-t Tocode [Filename ]]
Description
Use the uconv command to convert the encoding of characters read from either standard input or the specified file from one coded character set (CCSID) to another and then write the results to standard output.The uconv command follows the ICU (International Components for Unicode) standard. That is, it internally converts characters in FromCode coded character set to Unicode (UTF-16) before converting back to the ToCode coded character set. For more information about the ICU standard, including APIs that can be used with uconv, visit the ICU Home Page.
You can use the listconv command to show the available CCSIDs. For more information, see listconv command: list all the default converters in CCSID.
Flags
You can use these flags with the uconv command:- -f FromCode
- Specifies the coded character set in which the input data is encoded. The space between the -f flag and FromCode is required. The input data set should consist of characters in the coded character set identified by FromCode.
- -t ToCode [FileName]
- Specifies the code paeg in which the output data is encoded. The space between the
-t flag and ToCode is required.
If FileName is not specified, uconv reads from the standard input.
Exit status
The uconv command returns these exit statuses:- 0
- Input data successfully converted.
- 1
- File cannot be opened.
- 2
- Code set converter is not supported.
- 3
- Bad block size.
- 4
- Unknown callback
Note: If you want to run the uconv command, you can either set the environment variable ICU_DATA to point to the /usr/lpp/psf/bin
(for AIX or Linux) or <install_path>\bin
(for Windows) or you can run the command following these examples:
Examples
To convert the contents of theibm850.txt
file from coded character set IBM-850 to UTF-16 and store the results in utf.tmp
file, enter:- for AIX or Linux:
ICU_DATA=/usr/lpp/psf/bin/ uconv -f IBM-850 -t UTF-16 ibm850.txt > utf.tmp
- for Windows:
ICU_DATA=<install_path>\bin uconv -f IBM-850 -t UTF-16 ibm850.txt > utf.tmp
To convert an ASCII coded character set to an EBCDIC coded character set, open a Command Prompt window and type:
- for AIX or Linux:
ICU_DATA=/usr/lpp/psf/bin/ uconv -f 850 -t 500 input.txt > output.txt
- for Windows:
ICU_DATA=<install_path>\bin uconv -f 850 -t 500 input.txt > output.txt