Package ej.hoka.http.support
Class UrlDecoder
- java.lang.Object
-
- ej.hoka.http.support.UrlDecoder
-
public final class UrlDecoder extends java.lang.ObjectUtilities for decoding percent encoded characters.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intdecode(java.io.InputStream is, java.lang.StringBuilder sb)Returns the character from the stream, which encode as "%ab" (single byte UTF-8) or "%ab%cd" (two byte ).
-
-
-
Method Detail
-
decode
public static int decode(java.io.InputStream is, java.lang.StringBuilder sb) throws java.io.IOExceptionReturns the character from the stream, which encode as "%ab" (single byte UTF-8) or "%ab%cd" (two byte ). The initial % mark has been already reed. The character is represented as %ab where "a" and "b" is a hexa character (0-9, A-F) if the value of (a * 16 + b) > 127 the next 3 bytes will be read as the second byte of a two-byte UTF-8 char. When a character encoding problem is encountered, returns -1 (ffff). Since there is no unicode character with this code, this does not cause problems. When a percentage encoded UTF-16 Surrogate Pair is encountered (integer value above 0xFFFF) this method calculates the head and trail surrogate code point for the Unicode character. The head code point is inserted into theStringBuilderand the tail surrogate is returned. If the code doesn't denote a surrogate pair (value is less than 0xFFFF) simply return it.- Parameters:
is- theInputStream.sb- theStringBuilder.- Returns:
- the original code (if code's value less than 0xFFFF) or the tail surrogate code point of the surrogate pair.
- Throws:
java.io.IOException- if an I/O error occurred readingis.
-
-