int Scan() { for (;;) { int next; state = currentStart; while ((next = NextState()) == goStart) { code = buffer.Read(); } state = next; code = buffer.Read(); while ((next = NextState()) > eofNum) { state = next; code = buffer.Read(); } if (state <= maxAccept) { #region ActionSwitch #pragma warning disable 162 switch (state) { case eofNum: switch (currentStart) { case 11: if (utfX == 0 && uppr == 0) { return(-1); /* raw ascii */ } else if (uppr * 10 > utfX) { return(0); /* default code page */ } else { return(65001); /* UTF-8 encoding */ } break; } return(EndToken); case 1: // Recognized '{Upper128}', Shortest string "\xC0" case 2: // Recognized '{Upper128}', Shortest string "\x80" case 3: // Recognized '{Upper128}', Shortest string "\xE0" case 4: // Recognized '{Upper128}', Shortest string "\xF0" uppr++; break; case 5: // Recognized '{Utf8pfx4}{Utf8cont}', Shortest string "\xF0\x80" uppr += 2; break; case 6: // Recognized '{Utf8pfx4}{Utf8cont}{2}', Shortest string "\xF0\x80\x80" uppr += 3; break; case 7: // Recognized '{Utf8pfx4}{Utf8cont}{3}', Shortest string "\xF0\x80\x80\x80" utfX += 3; break; case 8: // Recognized '{Utf8pfx3}{Utf8cont}', Shortest string "\xE0\x80" uppr += 2; break; case 9: // Recognized '{Utf8pfx3}{Utf8cont}{2}', Shortest string "\xE0\x80\x80" utfX += 2; break; case 10: // Recognized '{Utf8pfx2}{Utf8cont}', Shortest string "\xC0\x80" utfX++; break; default: break; } #pragma warning restore 162 #endregion } } }
public void SetSource(Stream source) { buffer = new BuildBuffer(source); code = buffer.Read(); }
public void SetSource(System.IO.Stream source) { this.buffer = new BuildBuffer(source); code = buffer.Read(); }