yinyl
package com.yin.test;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
 * @author User
 *
 */
public class MyTestClass
{
public static void main(String[] args)
{
      
    String str = "测试字符转换 a beautiful girl"; //默认环境,已是UTF-8编码  
    try {  
        String strGBK = URLEncoder.encode(str, "GBK");  
        System.out.println(strGBK);  
        String strUTF8 = URLDecoder.decode(str, "UTF-8");  
        System.out.println(strUTF8);  
    } catch (UnsupportedEncodingException e) {  
        e.printStackTrace();  
    }  
}
}

转码技术一般用于数据传递,防止中文乱的出现,导致数据异常~

分类:

技术点:

相关文章:

  • 2021-11-27
  • 2021-09-24
  • 2021-10-16
  • 2021-09-24
  • 2021-08-13
  • 2021-11-05
  • 2021-11-05
猜你喜欢
  • 2021-11-27
  • 2021-12-10
  • 2021-11-13
  • 2021-07-19
  • 2021-11-30
  • 2021-10-16
  • 2021-12-04
相关资源
相似解决方案