@Test public void testEscaping() throws Exception { String original = "A(B)C,D\\E!F<G=H>I~J;K*L+M\rN\nO\tP Q\u20AC"; String escaped = BytesBlock.escape(original); assert "A\\28B\\29C\\2cD\\5cE\\21F\\3cG\\3dH\\3eI\\7eJ\\3bK\\2aL\\2bM\\0dN\\0aO\\09P Q\u20AC".equals(escaped); }
protected static String escape(String value) { if (value == null) return null; StringBuilder result = new StringBuilder(); for (int i = 0; i < value.length(); ++i) { char c = value.charAt(i); if (c < reservedChars.length && reservedChars[c] == c) { result.append("\\"); int code = c & 0xFF; if (code < 16) result.append("0"); result.append(Integer.toHexString(code)); } else { result.append(c); } } return result.toString(); }
BytesBlock { protected static String escape(String value) { if (value == null) return null; StringBuilder result = new StringBuilder(); for (int i = 0; i < value.length(); ++i) { char c = value.charAt(i); if (c < reservedChars.length && reservedChars[c] == c) { result.append("\\"); int code = c & 0xFF; if (code < 16) result.append("0"); result.append(Integer.toHexString(code)); } else { result.append(c); } } return result.toString(); } }
BytesBlock { protected static String escape(String value) { if (value == null) return null; StringBuilder result = new StringBuilder(); for (int i = 0; i < value.length(); ++i) { char c = value.charAt(i); if (c < reservedChars.length && reservedChars[c] == c) { result.append("\\"); int code = c & 0xFF; if (code < 16) result.append("0"); result.append(Integer.toHexString(code)); } else { result.append(c); } } return result.toString(); }  }
BytesBlock { protected static String escape(String value) { if (value == null) return null; StringBuilder result = new StringBuilder(); for (int i = 0; i < value.length(); ++i) { char c = value.charAt(i); if (c < reservedChars.length && reservedChars[c] == c) { result.append("\\"); int code = c & 0xFF; if (code < 16) result.append("0"); result.append(Integer.toHexString(code)); } else { result.append(c); } } return result.toString(); }   }
BytesBlock { protected static String escape(String value) { if (value == null) return null; StringBuilder result = new StringBuilder(); for (int i = 0; i < value.length(); ++i) { char c = value.charAt(i); if (c < reservedChars.length && reservedChars[c] == c) { result.append("\\"); int code = c & 0xFF; if (code < 16) result.append("0"); result.append(Integer.toHexString(code)); } else { result.append(c); } } return result.toString(); }    }