Here you can find the source of decodeURI(String s)
decodeURIComponent
function.
Parameter | Description |
---|---|
s | The UTF-8 encoded String to be decoded |
public static String decodeURI(String s)
//package com.java2s; //License from project: LGPL import java.net.URLDecoder; public class Main { /**/*from ww w .j ava2s . c o m*/ * Decodes the passed UTF-8 String using an algorithm that's compatible with * JavaScript's * <code>decodeURIComponent</code> function. Returns * <code>null</code> if the String is * <code>null</code>. * * @param s The UTF-8 encoded String to be decoded * @return the decoded String */ public static String decodeURI(String s) { if (s == null) { return null; } String result; try { result = URLDecoder.decode(s, "UTF-8"); } // This exception should never occur. catch (Exception e) { result = s; } return result; } }