Linux 命令 iconv 轉換編碼

2021-09-13 13:06:56 字數 912 閱讀 9314

iconv是 linux 系統自帶的用於轉換檔案編碼的命令列工具。
使用iconv --help命令檢視命令幫助資訊:

用法: iconv [option...] [-f encoding] [-t encoding] [inputfile...]

或者: iconv -l

將文字從一種編碼轉換成另一種編碼。

控制輸入輸出格式的選項:

-f encoding, --from-code=encoding

輸入編碼

-t encoding, --to-code=encoding

輸出編碼

控制字元轉換的選項:

-c 忽略不可轉換的字元

--unicode-subst=formatstring

替代不可轉換的 unicode 字元

--byte-subst=formatstring 替代不可轉換的位元組

--widechar-subst=formatstring

替代不可轉換的寬字元

控制錯誤輸出的選項:

-s, --silent 不顯示有關轉換出錯的資訊

輸出資訊:

-l, --list 列出支援的編碼

--help 顯示此幫助並退出

--version 顯示版本資訊並退出

iconv -l
iconv -f encoding -t encoding inputfile

linux 編碼型別轉換 iconv

用途說明 iconv命令是用來轉換檔案的編碼方式的 convert encoding of given files from one encoding to another 比如它可以將utf8編碼的轉換成gb18030的編碼,反過來也行。jdk中也提供了類似的工具native2ascii。linu...

Linux使用iconv進行編碼轉換

最近在做專案,為了能讓ui顯示中文,需要對中文進行編碼轉換。因為我用的是directfb,它只支援utf 8格式,所以要將gb2312轉換為utf 8,這時使用iconv是非常方便的。以下是我在專案中用到的一部分 首先要使用iconv的api需要包含它的標頭檔案 include iconv.h 或者...

Linux系統中轉換編碼格式

iconv f 原始編碼 t 需要的編碼 words.txt 另存為的檔名 如果你需要在linux中操作windows下的檔案,那麼你可能會經常遇到檔案編碼轉換的問題。windows中預設的檔案格式是gbk gb2312 而linux一般都是utf 8。下面介紹一下,在linux中如何檢視檔案的編碼...