Java tutorial
//package com.java2s; import java.net.URLEncoder; public class Main { public static String encodeUrl(String inputUrl) { if (isBlank(inputUrl)) return inputUrl; char[] charArray = inputUrl.toCharArray(); for (int i = 0; i < charArray.length; i++) { if ((charArray[i] >= 0x4e00) && (charArray[i] <= 0x9fbb)) { inputUrl = inputUrl.replaceFirst(String.valueOf(charArray[i]), URLEncoder.encode(String.valueOf(charArray[i]))); } } return inputUrl; } public static boolean isBlank(String input) { if (input == null || "".equals(input)) return true; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { return false; } } return true; } }