package unicode;

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

public class unicodeTest {

	public static void main(String[] args) {
		String shang = "Yeah";
		String result = "";
		System.out.println(shang);
		try {
			result = URLEncoder.encode(shang, "GBK");
			System.out.println("GBK:" + result);
			
		    result = URLEncoder.encode(shang, "UTF-8");
			System.out.println("UTF8: " + result);
			
			result = URLEncoder.encode(shang, "UTF-16");
			System.out.println("UTF16:" + result);
		} catch(UnsupportedEncodingException e) { e.printStackTrace(); }}}Copy the code

Output:

War GBK:%E9%E4 UTF8: %E6%AE%87 UTF16:%FE%FF%6B%87