zoukankan      html  css  js  c++  java
  • java中文乱码解决方法汇总

    public static void main(String[] argv){

    try {
        
               System.out.println(“中文”);//1
     
               System.out.println(“中文”.getBytes());//2
     
               System.out.println(“中文”.getBytes(“GB2312″));//3
     
               System.out.println(“中文”.getBytes(“ISO8859_1″));//4
              
     
               System.out.println(new String(“中文”.getBytes()));//5
     
               System.out.println(new String(“中文”.getBytes(),”GB2312″));//6
     
               System.out.println(new String(“中文”.getBytes(),”ISO8859_1″));//7
     
               System.out.println(new String(“中文”.getBytes(“GB2312″)));//8
     
               System.out.println(new String(“中文”.getBytes(“GB2312″),”GB2312″));//9
              
     
               System.out.println(new String(“中文”.getBytes(“GB2312″),”ISO8859_1″));//10
     
               System.out.println(new String(“中文”.getBytes(“ISO8859_1″)));//11
     
               System.out.println(new String(“中文”.getBytes(“ISO8859_1″),”utf-8″));//12
     
               System.out.println(new String(“中文发送短信”.getBytes(“ISO8859_1″),”utf-8″));//13
              
               //编码与解码
               String cont=URLEncoder.encode(new String(“你在干什么啊  33335″),utf-8″);
               System.out.println(“0:”+cont);          
               String after=URLDecoder.decode(cont,utf-8″);
               System.out.println(“1:”+after);
              
          } catch (Exception e) {
        System.out.println(e.getMessage());
        }
     
    }
  • 相关阅读:
    Python那些优雅的写法:switch-case
    python将print输出的信息保留到日志文件中
    Python 获取被调用函数名称,所处模块,被调用代码行
    python **运算符及多参数传参
    使用Docker之镜像的拉取、查询、删除
    资料
    kmp算法
    开源软件
    golang之http请求的dns解析代码流程
    Go语言从HTTP请求中获取服务端IP地址
  • 原文地址:https://www.cnblogs.com/husam/p/3807498.html
Copyright © 2011-2022 走看看