/** * Decode '%HH'. */ private static String decode(String s) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); for( int i=0; i<s.length();i++ ) { char ch = s.charAt(i); if(ch=='%') { baos.write(hexToInt(s.charAt(i+1))*16 + hexToInt(s.charAt(i+2))); i+=2; continue; } baos.write(ch); } try { return new String(baos.toByteArray(),"UTF-8"); } catch (UnsupportedEncodingException e) { throw new Error(e); // impossible } }
/** * Decode '%HH'. */ private static String decode(String s) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); for( int i=0; i<s.length();i++ ) { char ch = s.charAt(i); if(ch=='%') { baos.write(hexToInt(s.charAt(i+1))*16 + hexToInt(s.charAt(i+2))); i+=2; continue; } baos.write(ch); } try { return new String(baos.toByteArray(),"UTF-8"); } catch (UnsupportedEncodingException e) { throw new Error(e); // impossible } }
/** * Decode '%HH'. */ private static String decode(String s) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); for( int i=0; i<s.length();i++ ) { char ch = s.charAt(i); if(ch=='%') { baos.write(hexToInt(s.charAt(i+1))*16 + hexToInt(s.charAt(i+2))); i+=2; continue; } baos.write(ch); } try { return new String(baos.toByteArray(),"UTF-8"); } catch (UnsupportedEncodingException e) { throw new Error(e); // impossible } }
/** * Decode '%HH'. */ private static String decode(String s) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); for( int i=0; i<s.length();i++ ) { char ch = s.charAt(i); if(ch=='%') { baos.write(hexToInt(s.charAt(i+1))*16 + hexToInt(s.charAt(i+2))); i+=2; continue; } baos.write(ch); } try { return new String(baos.toByteArray(),"UTF-8"); } catch (UnsupportedEncodingException e) { throw new Error(e); // impossible } }