Methods Summary |
---|
public final java.io.Reader | chain(java.io.Reader rdr)Creates a new EscapeUnicode using the passed in
Reader for instantiation.
EscapeUnicode newFilter = new EscapeUnicode(rdr);
newFilter.setInitialized(true);
return newFilter;
|
private void | initialize()Parses the parameters (currently unused)
|
public final int | read()Returns the next character in the filtered stream, converting non latin
characters to unicode escapes.
if (!getInitialized()) {
initialize();
setInitialized(true);
}
int ch = -1;
if (unicodeBuf.length() == 0) {
ch = in.read();
if (ch != -1) {
char achar = (char) ch;
if (achar >= '\u0080") {
unicodeBuf = new StringBuffer("u0000");
String s = Integer.toHexString(ch);
//replace the last 0s by the chars contained in s
for (int i = 0; i < s.length(); i++) {
unicodeBuf.setCharAt(unicodeBuf.length()
- s.length() + i,
s.charAt(i));
}
ch = '\\";
}
}
} else {
ch = (int) unicodeBuf.charAt(0);
unicodeBuf.deleteCharAt(0);
}
return ch;
|