23 lines
720 B
Java
23 lines
720 B
Java
package de.financer.controller;
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.net.URLDecoder;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
public class ControllerUtil {
|
|
/**
|
|
* This method decodes the given URL encoded string, e.g. replaces <code>%20</code> with a space.
|
|
*
|
|
* @param toDecode the string to decode
|
|
* @return the decoded string in UTF-8 or, if UTF-8 is not available for whatever reason, the encoded string
|
|
*/
|
|
public static final String urlDecode(String toDecode) {
|
|
try {
|
|
return URLDecoder.decode(toDecode, StandardCharsets.UTF_8.name());
|
|
}
|
|
catch (UnsupportedEncodingException e) {
|
|
return toDecode;
|
|
}
|
|
}
|
|
}
|