Java tutorial
//package com.java2s; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String encodeUrl(String url) { String new_url = url; Matcher matcher = Pattern.compile("[\\u4e00-\\u9fa5]").matcher(new_url); while (matcher.find()) { try { new_url = new_url.replaceAll(matcher.group(), URLEncoder.encode(matcher.group(), "gb2312")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } return new_url; } }