Tidy.Core.OutImpl.Outc C# (CSharp) Method

Outc() public method

public Outc ( int c ) : void
c int
return void
        public override void Outc(int c)
        {
            try
            {
                switch (Encoding)
                {
                    case CharEncoding.Utf8:
                        if (c < 128)
                        {
                            Output.WriteByte((byte) c);
                        }
                        else
                        {
                            int ch;
                            if (c <= 0x7FF)
                            {
                                ch = (0xC0 | (c >> 6));
                                Output.WriteByte((byte) ch);
                                ch = (0x80 | (c & 0x3F));
                                Output.WriteByte((byte) ch);
                            }
                            else if (c <= 0xFFFF)
                            {
                                ch = (0xE0 | (c >> 12));
                                Output.WriteByte((byte) ch);
                                ch = (0x80 | ((c >> 6) & 0x3F));
                                Output.WriteByte((byte) ch);
                                ch = (0x80 | (c & 0x3F));
                                Output.WriteByte((byte) ch);
                            }
                            else if (c <= 0x1FFFFF)
                            {
                                ch = (0xF0 | (c >> 18));
                                Output.WriteByte((byte) ch);
                                ch = (0x80 | ((c >> 12) & 0x3F));
                                Output.WriteByte((byte) ch);
                                ch = (0x80 | ((c >> 6) & 0x3F));
                                Output.WriteByte((byte) ch);
                                ch = (0x80 | (c & 0x3F));
                                Output.WriteByte((byte) ch);
                            }
                            else
                            {
                                ch = (0xF8 | (c >> 24));
                                Output.WriteByte((byte) ch);
                                ch = (0x80 | ((c >> 18) & 0x3F));
                                Output.WriteByte((byte) ch);
                                ch = (0x80 | ((c >> 12) & 0x3F));
                                Output.WriteByte((byte) ch);
                                ch = (0x80 | ((c >> 6) & 0x3F));
                                Output.WriteByte((byte) ch);
                                ch = (0x80 | (c & 0x3F));
                                Output.WriteByte((byte) ch);
                            }
                        }
                        break;
                    case CharEncoding.Iso2022:
                        if (c == 0x1b)
                        {
                            /* ESC */
                            State = StreamIn.FSM_ESC;
                        }
                        else
                        {
                            switch (State)
                            {
                                case StreamIn.FSM_ESC:
                                    if (c == '$')
                                    {
                                        State = StreamIn.FSM_ESCD;
                                    }
                                    else if (c == '(')
                                    {
                                        State = StreamIn.FSM_ESCP;
                                    }
                                    else
                                    {
                                        State = StreamIn.FSM_ASCII;
                                    }
                                    break;

                                case StreamIn.FSM_ESCD:
                                    State = c == '(' ? StreamIn.FSM_ESCDP : StreamIn.FSM_NONASCII;
                                    break;

                                case StreamIn.FSM_ESCDP:
                                    State = StreamIn.FSM_NONASCII;
                                    break;

                                case StreamIn.FSM_ESCP:
                                    State = StreamIn.FSM_ASCII;
                                    break;

                                case StreamIn.FSM_NONASCII:
                                    c &= 0x7F;
                                    break;
                            }
                        }
                        Output.WriteByte((byte) c);
                        break;
                    default:
                        Output.WriteByte((byte) c);
                        break;
                }
            }
            catch (IOException e)
            {
                Debug.WriteLine("OutImpl.outc: " + e);
            }
        }

Same methods

OutImpl::Outc ( sbyte c ) : void