Decodes a string of characters in the range [U+0000, U+007F] to bytes. Each percent-encoded sequence (e.g. "%F0" or "%2a", as defined by RFC 3986 2.1) is decoded to the octet it encodes. Other characters are decoded to their code point's single byte value. A literal % character must be encoded a
(CharSequence s)
| 1055 | * encoding sequences. |
| 1056 | */ |
| 1057 | public static ByteBuffer percentDecode(CharSequence s) { |
| 1058 | // This is large enough because each input character needs *at most* one byte of output. |
| 1059 | ByteBuffer outBuf = ByteBuffer.allocate(s.length()); |
| 1060 | percentDecode(s, "input", null, outBuf); |
| 1061 | outBuf.flip(); |
| 1062 | return outBuf; |
| 1063 | } |
| 1064 | |
| 1065 | private static void percentDecode( |
| 1066 | CharSequence s, String what, BitSet allowedChars, ByteBuffer outBuf) { |
no test coverage detected