UrlEncoded extends MultiMap<String> implements Cloneable { public void decode(String query) { decodeTo(query, this, ENCODING); } UrlEncoded(UrlEncoded url);  UrlEncoded();  UrlEncoded(String query); static String encode(MultiMap<String> map, Charset charset, boolean equalsForNullValue); static void decodeTo(String content, MultiMap<String> map, String charset); static void decodeTo(String content, MultiMap<String> map, Charset charset); static void decodeUtf8To(String query, MultiMap<String> map); static void decodeUtf8To(String query, int offset, int length, MultiMap<String> map); static void decode88591To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys); static void decodeUtf8To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys); static void decodeUtf16To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys); static void decodeTo(InputStream in, MultiMap<String> map, String charset, int maxLength, int maxKeys); static void decodeTo(InputStream in, MultiMap<String> map, Charset charset, int maxLength, int maxKeys); static String decodeString(String encoded); static String decodeString(String encoded, int offset, int length, Charset charset); static String encodeString(String string); static String encodeString(String string, Charset charset); void decode(String query); void decode(String query, Charset charset); String encode(); String encode(Charset charset); String encode(Charset charset, boolean equalsForNullValue); @Override Object clone(); static final Charset ENCODING; }
@Test void testUtf8() throws Exception { UrlEncoded url_encoded = new UrlEncoded(); assertEquals(0, url_encoded.size()); url_encoded.clear(); url_encoded.decode("text=%E0%B8%9F%E0%B8%AB%E0%B8%81%E0%B8%A7%E0%B8%94%E0%B8%B2%E0%B9%88%E0%B8%81%E0%B8%9F%E0%B8%A7%E0%B8%AB%E0%B8%AA%E0%B8%94%E0%B8%B2%E0%B9%88%E0%B8%AB%E0%B8%9F%E0%B8%81%E0%B8%A7%E0%B8%94%E0%B8%AA%E0%B8%B2%E0%B8%9F%E0%B8%81%E0%B8%AB%E0%B8%A3%E0%B8%94%E0%B9%89%E0%B8%9F%E0%B8%AB%E0%B8%99%E0%B8%81%E0%B8%A3%E0%B8%94%E0%B8%B5&Action=Submit"); String hex = "E0B89FE0B8ABE0B881E0B8A7E0B894E0B8B2E0B988E0B881E0B89FE0B8A7E0B8ABE0B8AAE0B894E0B8B2E0B988E0B8ABE0B89FE0B881E0B8A7E0B894E0B8AAE0B8B2E0B89FE0B881E0B8ABE0B8A3E0B894E0B989E0B89FE0B8ABE0B899E0B881E0B8A3E0B894E0B8B5"; String expected = new String(TypeUtils.fromHexString(hex), "utf-8"); assertEquals(expected, url_encoded.getString("text")); }
@Test void testUtf8_MultiByteCodePoint() { String input = "text=test%C3%A4"; UrlEncoded url_encoded = new UrlEncoded(); url_encoded.decode(input); String expected = "test\u00e4"; assertEquals(expected, url_encoded.getString("text")); }