public override int decode(InStream @in) { int c1 = @in.r(); int c2 = @in.r(); if ((c1 | c2) < 0) { return(-1); } return(c1 | (c2 << 8)); }
public override int decode(InStream @in) { int c = @in.r(); if (c < 0) { return(-1); } int c2, c3; switch (c >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: /* 0xxxxxxx*/ return(c); case 12: case 13: /* 110x xxxx 10xx xxxx*/ c2 = @in.r(); if ((c2 & 0xC0) != 0x80) { throw IOErr.make("Invalid UTF-8 encoding").val; } return(((c & 0x1F) << 6) | (c2 & 0x3F)); case 14: /* 1110 xxxx 10xx xxxx 10xx xxxx */ c2 = @in.r(); c3 = @in.r(); if (((c2 & 0xC0) != 0x80) || ((c3 & 0xC0) != 0x80)) { throw IOErr.make("Invalid UTF-8 encoding").val; } return(((c & 0x0F) << 12) | ((c2 & 0x3F) << 6) | ((c3 & 0x3F) << 0)); default: throw IOErr.make("Invalid UTF-8 encoding").val; } }
public override int decode(InStream @in) { // TODO - well shit, how do we know how many bytes to read generically? int len = 1; int b = @in.r(); if (b < 0) { return(-1); } bbuf[0] = (byte)b; cbuf = charset.m_encoding.GetChars(bbuf, 0, len); return(cbuf[0]); }
public override int decode(InStream @in) { return(@in.r()); }
public override int decode(InStream @in) { int c = @in.r(); if (c < 0) return -1; int c2, c3; switch (c >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: /* 0xxxxxxx*/ return c; case 12: case 13: /* 110x xxxx 10xx xxxx*/ c2 = @in.r(); if ((c2 & 0xC0) != 0x80) throw IOErr.make("Invalid UTF-8 encoding").val; return ((c & 0x1F) << 6) | (c2 & 0x3F); case 14: /* 1110 xxxx 10xx xxxx 10xx xxxx */ c2 = @in.r(); c3 = @in.r(); if (((c2 & 0xC0) != 0x80) || ((c3 & 0xC0) != 0x80)) throw IOErr.make("Invalid UTF-8 encoding").val; return (((c & 0x0F) << 12) | ((c2 & 0x3F) << 6) | ((c3 & 0x3F) << 0)); default: throw IOErr.make("Invalid UTF-8 encoding").val; } }
public override int decode(InStream @in) { int c1 = @in.r(); int c2 = @in.r(); if ((c1 | c2) < 0) return -1; return (c1 | (c2 << 8)); }
public override int decode(InStream @in) { return @in.r(); }
public override int decode(InStream @in) { // TODO - well shit, how do we know how many bytes to read generically? int len = 1; int b = @in.r(); if (b < 0) return -1; bbuf[0] = (byte)b; cbuf = charset.m_encoding.GetChars(bbuf, 0, len); return cbuf[0]; }