@Test public void testEncodeWithPercent() { StringBuilder sb = new StringBuilder(); RFC2231.percentEscape(sb, "foo"); assertEquals("foo", sb.toString()); sb.setLength(0); RFC2231.percentEscape(sb, "foo bar"); assertEquals("foo%20bar", sb.toString()); sb.setLength(0); RFC2231.percentEscape(sb, "R\u00e9sultat d'Activit\u00e9 (;provisoire/draft)."); assertEquals("R%C3%A9sultat%20d%27Activit%C3%A9%20%28%3Bprovisoire/draft%29.", sb.toString()); }
public static void percentEscape(StringBuilder sb, String value) { byte[] bytes = value.getBytes(UTF_8); for (byte b : bytes) { if (b < '+' || b == ';' || b == ',' || b == '\\' || b > 'z') { sb.append('%'); String s = Integer.toHexString(b & 0xff).toUpperCase(); if (s.length() < 2) { sb.append('0'); } sb.append(s); } else { sb.append((char) b); } } }
RFC2231 { public static void percentEscape(StringBuilder sb, String value) { byte[] bytes = value.getBytes(UTF_8); for (byte b : bytes) { if (b < '+' || b == ';' || b == ',' || b == '\\' || b > 'z') { sb.append('%'); String s = Integer.toHexString(b & 0xff).toUpperCase(); if (s.length() < 2) { sb.append('0'); } sb.append(s); } else { sb.append((char) b); } } } }
RFC2231 { public static void percentEscape(StringBuilder sb, String value) { byte[] bytes = value.getBytes(UTF_8); for (byte b : bytes) { if (b < '+' || b == ';' || b == ',' || b == '\\' || b > 'z') { sb.append('%'); String s = Integer.toHexString(b & 0xff).toUpperCase(); if (s.length() < 2) { sb.append('0'); } sb.append(s); } else { sb.append((char) b); } } } private  RFC2231(); }
RFC2231 { public static void percentEscape(StringBuilder sb, String value) { byte[] bytes = value.getBytes(UTF_8); for (byte b : bytes) { if (b < '+' || b == ';' || b == ',' || b == '\\' || b > 'z') { sb.append('%'); String s = Integer.toHexString(b & 0xff).toUpperCase(); if (s.length() < 2) { sb.append('0'); } sb.append(s); } else { sb.append((char) b); } } } private  RFC2231(); static void percentEscape(StringBuilder sb, String value); static String encodeContentDisposition(String filename, boolean inline, String userAgent); }
RFC2231 { public static void percentEscape(StringBuilder sb, String value) { byte[] bytes = value.getBytes(UTF_8); for (byte b : bytes) { if (b < '+' || b == ';' || b == ',' || b == '\\' || b > 'z') { sb.append('%'); String s = Integer.toHexString(b & 0xff).toUpperCase(); if (s.length() < 2) { sb.append('0'); } sb.append(s); } else { sb.append((char) b); } } } private  RFC2231(); static void percentEscape(StringBuilder sb, String value); static String encodeContentDisposition(String filename, boolean inline, String userAgent);  }