public override int Read()

in Pixie/SqlScanner.cs [1520:1580]


            public override int Read()
            {
                int ch0 = bStrm.ReadByte();
                int ch1, ch2, ch3,ch4, ch5;
                int result = UnicodeReplacementChar;

                if (ch0 < 0x7f)
                {
                    delta = (ch0 == EOF ? 0 : 1);
                    result = ch0;
                }
                else if ((ch0 & 0xe0) == 0xc0)
                {
                    delta = 2;
                    ch1 = bStrm.ReadByte();
                    if ((ch1 & 0xc0) == 0x80)
                        result = ((ch0 & 0x1f) << 6) + (ch1 & 0x3f);
                }
                else if ((ch0 & 0xf0) == 0xe0)
                {
                    delta = 3;
                    ch1 = bStrm.ReadByte(); ch2 = bStrm.ReadByte();
                    if ((ch1 & 0xc0) == 0x80 && (ch2 & 0xc0) == 0x80)
                        result = ((ch0 & 0xf) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f);
                }
                else if ((ch0 & 0xf8) == 0xf0)
                {
                    delta = 4;
                    ch1 = bStrm.ReadByte(); ch2 = bStrm.ReadByte(); ch3 = bStrm.ReadByte();
                    if ((ch1 & 0xc0) == 0x80 && (ch2 & 0xc0) == 0x80 && (ch3 & 0xc0) == 0x80)
                    {
                        result = ((ch0 & 0x7) << 18) + ((ch1 & 0x3f) << 12) + 
                                 ((ch2 & 0x3f) << 6) + (ch3 & 0x3f);
                    }
                }
                else if ((ch0 & 0xfc) == 0xf8)
                {
                    delta = 5;
                    ch1 = bStrm.ReadByte(); ch2 = bStrm.ReadByte();
                    ch3 = bStrm.ReadByte(); ch4 = bStrm.ReadByte();
                    if ((ch1 & 0xc0) == 0x80 && (ch2 & 0xc0) == 0x80 && (ch3 & 0xc0) == 0x80 && (ch4 & 0xc0) == 0x80)
                    {
                        result = ((ch0 & 0x3) << 24) + ((ch1 & 0x3f) << 18) + 
                                     ((ch2 & 0x3f) << 12) + ((ch3 & 0x3f) << 6) + (ch4 & 0x3f);
                    }
                }
                else if ((ch0 & 0xfe) == 0xfc)
                {
                    delta = 6;
                    ch1 = bStrm.ReadByte(); ch2 = bStrm.ReadByte(); ch3 = bStrm.ReadByte();
                    ch4 = bStrm.ReadByte(); ch5 = bStrm.ReadByte();

                    if ((ch1 & 0xc0) == 0x80 && (ch2 & 0xc0) == 0x80 && 
                        (ch3 & 0xc0) == 0x80 && (ch4 & 0xc0) == 0x80 && (ch5 & 0xc0) == 0x80)
                    {
                        result = ((ch0 & 0x1) << 28) + ((ch1 & 0x3f) << 24) + ((ch2 & 0x3f) << 18) + 
                                     ((ch3 & 0x3f) << 12) + ((ch4 & 0x3f) << 6) + (ch5 & 0x3f);
                    }
                }
                return result;
            }