zoukankan      html  css  js  c++  java
  • 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.
    

    名子相同也可以:

    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
    

     =======================================================================

    [root@NGINX-APACHE-SVN pro]# file 交互式创建apache虚拟主机.txt 
    交互式创建apache虚拟主机.txt: Bourne-Again shell script text executable
    #这是个shell肢本,但里面有中文,显示为乱码!

    同样用iconv命令来除理,结果成功了!

    [root@NGINX-APACHE-SVN pro]# iconv -f GBK -t UTF-8 交互式创建apache虚拟主机.txt -o 交互式创建apache虚拟主机.txt 

    如果去掉#!/bin/bash 再次查看:

    [root@NGINX-APACHE-SVN pro]# file  交互式创建apache虚拟主机.txt 
    交互式创建apache虚拟主机.txt: ISO-8859 text, with CRLF line terminators

    所以这个乱码的问题,可以用上面的方法去解决!!

  • 相关阅读:
    ajax加载数据字典下拉选后台
    【算法】二叉树前中后序的递归+迭代(java代码)
    【设计模式】代理模式与装饰器模式的区别
    《重构》读书笔记(一)
    【服务器安全】记一次处理挖矿病毒经历
    【计算机原理】数值存储计算基本理论(一)
    【JAVA】java中类的执行顺序
    【numpy&pandas】Pandas速查笔记
    【前端】打包vue项目到nginx过程
    【服务器搭建】Linux下安装docker
  • 原文地址:https://www.cnblogs.com/bass6/p/5711221.html
Copyright © 2011-2022 走看看