Linux之iconv轉換文字格式的問題

2021-09-23 17:51:55 字數 953 閱讀 8545

在linux上遇到了文字格式的問題:iso-8859 text 出現了亂碼,需要轉換格式到utf-8

[lf_bde@dsj-nlkf-96 ks2016]$ file dwa_v_m_guoan_comp_011_201608.txt

dwa_v_m_guoan_comp_011_201608.txt: iso-8859 text

iconv的用法是:

iconv -f from-encoding -t to-encoding inputfile -o outputfile
於是按照自己的想法 是把iso-8859 text 轉換到 utf-8格式 於是:

iconv -f iso-8859 -t utf-8 dwa_v_m_guoan_comp_011_201608.txt1 -o dwa_v_m_guoan_comp_011_20160801.txt
但是,並沒有成功,出現了錯誤:

iconv: conversion to `iso-8859' is not supported

try `iconv --help' or `iconv --usage' for more information.

於是,換了一下寫法;

iconv -f gbk -t utf-8 dwa_v_m_guoan_comp_011_201608.txt -o dwa_v_m_guoan_comp_011_201608.txt
檢視檔案,成功了;

[lf_bde@dsj-nlkf-96 ks2016]$ file dwa_v_m_guoan_comp_011_201608.txt

dwa_v_m_guoan_comp_011_201608.txt: utf-8 unicode text

8 轉換文字函式

本系列文章均翻譯自make官方文件 make manual,github同步專案 question 不能被automake所識別。語法 value variable variable是變數的名字,而不是其引用。使用變數的值,值不會被擴充套件。foo path all echo foo echo va...

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 或者...