iconv 解決亂碼問題

 

[root@NGINX-APACHE-SVN pro]# file 林.txt 
林.txt: ISO-8859 text, with no line terminators
#在LINUX下顯示亂碼

 

[root@NGINX-APACHE-SVN pro]# iconv -f GBK -t UTF-8 林.txt -o 林1.txt 
[root@NGINX-APACHE-SVN pro]# file 林1.txt 
林1.txt: UTF-8 Unicode text, with no line terminators
 #問題解決!
[root@NGINX-APACHE-SVN pro]# file 林.txt 
林.txt: ISO-8859 text, with no line terminators

 

[root@NGINX-APACHE-SVN pro]# yum search iconv
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.btte.net
base                                                                              | 3.7 kB     00:00     
extras                                                                            | 3.4 kB     00:00     
updates                                                                           | 3.4 kB     00:00     
updates/primary_db                                                                | 1.4 MB     00:03     
========================================== N/S Matched: iconv ===========================================
perl-Text-Iconv.x86_64 : Perl interface to iconv() codeset conversion function

  Name and summary matches only, use "search all" for everything.
[root@NGINX-APACHE-SVN pro]# yum search iconv
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirror.bit.edu.cn
========================================== N/S Matched: iconv ===========================================
perl-Text-Iconv.x86_64 : Perl interface to iconv() codeset conversion function

  Name and summary matches only, use "search all" for everything.

名子相同也能夠:html

root@NGINX-APACHE-SVN pro]# file 20160704mysql.txt 
20160704mysql.txt: ISO-8859 text, with CRLF line terminators
 
[root@NGINX-APACHE-SVN pro]# iconv -f GBK -t UTF-8 20160704mysql.txt -o 20160704mysql.txt 
[root@NGINX-APACHE-SVN pro]# file 20160704mysql.txt 
20160704mysql.txt: UTF-8 Unicode text, with CRLF line terminators

 =======================================================================mysql

[root@NGINX-APACHE-SVN pro]# file 交互式建立apache虛擬主機.txt 
交互式建立apache虛擬主機.txt: Bourne-Again shell script text executable
#這是個shell肢本,但裏面有中文,顯示爲亂碼!

一樣用iconv命令來除理,結果成功了!sql

[root@NGINX-APACHE-SVN pro]# iconv -f GBK -t UTF-8 交互式建立apache虛擬主機.txt -o 交互式建立apache虛擬主機.txt 

若是去掉#!/bin/bash 再次查看:shell

[root@NGINX-APACHE-SVN pro]# file  交互式建立apache虛擬主機.txt 
交互式建立apache虛擬主機.txt: ISO-8859 text, with CRLF line terminators

因此這個亂碼的問題,能夠用上面的方法去解決!!apache

相關文章
相關標籤/搜索