@Override int read(final TextInput ti) throws IOException { final int a = ti.readByte(); if (a < 0) return a; final int b = ti.readByte(); if (b < 0) return invalid(); return a << 8 | b; }
@Override int read(final TextInput ti) throws IOException { final int a = ti.readByte(); if (a < 0) return a; final int b = ti.readByte(); if (b < 0) return invalid(); final int c = ti.readByte(); if (c < 0) return invalid(); final int d = ti.readByte(); if (d < 0) return invalid(); return a << 24 | b << 16 | c << 8 | d; }
@Override int read(final TextInput ti) throws IOException { int ch = ti.readByte(); if (ch < 0x80) return ch; if (ch < 0xC0) return invalid(); cache[0] = (byte) ch; final int cl = Token.cl((byte) ch); for (int c = 1; c < cl; ++c) { ch = ti.readByte(); if (ch < 0x80) return invalid(); cache[c] = (byte) ch; } return Token.cp(cache, 0); }
@Override int read(final TextInput ti) throws IOException { int c = -1; while (++c < 4) { final int ch = ti.readByte(); if (ch < 0) break; cache[c] = (byte) ch; outc.position(0); inc.position(0); inc.limit(c + 1); csd.reset(); final CoderResult cr = csd.decode(inc, outc, true); if (cr.isMalformed()) continue; // return character int i = 0; final int os = outc.position(); for (int o = 0; o < os; ++o) i |= outc.get(o) << (o << 3); return i; } return c == 0 ? -1 : invalid(); }