function format_ansi(controls, state, ansi_art) {
            var num;
            var styles = [];
            var output_color;
            var output_background;
            var _process_true_color = -1;
            var _ex_color = false;
            var _ex_background = false;
            var _process_8bit = false;
            var palette = $.terminal.ansi_colors.palette;
            function set_styles(num) {
                switch (num) {
                    case 0:
                        Object.keys(state).forEach(function(key) {
                            delete state[key];
                        });
                        state.blink = false;
                        state.bold = false;
                        state.faited = false;
                        break;
                    case 1:
                        styles.push('b');
                        state.bold = true;
                        state.faited = false;
                        break;
                    case 4:
                        styles.push('u');
                        break;
                    case 3:
                        styles.push('i');
                        break;
                    case 5:
                        if (_ex_color || _ex_background) {
                            _process_8bit = true;
                        } else {
                            state.blink = true;
                        }
                        break;
                    case 38:
                        _ex_color = true;
                        break;
                    case 48:
                        _ex_background = true;
                        break;
                    case 2:
                        if (_ex_color || _ex_background) {
                            _process_true_color = 0;
                        } else {
                            state.faited = true;
                            state.bold = false;
                        }
                        break;
                    case 7:
                        state.reverse = true;
                        break;
                    default:
                        if (color_list[num]) {
                            output_color = color_list[num];
                        }
                        if (background_list[num]) {
                            output_background = background_list[num];
                        }
                }
            }
            // -----------------------------------------------------------------
            function process_true_color() {
                if (_ex_color) {
                    if (!output_color) {
                        output_color = '#';
                    }
                    if (output_color.length < 7) {
                        output_color += ('0' + num.toString(16)).slice(-2);
                    }
                }
                if (_ex_background) {
                    if (!output_background) {
                        output_background = '#';
                    }
                    if (output_background.length < 7) {
                        output_background += ('0' + num.toString(16)).slice(-2);
                    }
                }
                if (_process_true_color === 2) {
                    _process_true_color = -1;
                } else {
                    _process_true_color++;
                }
            }
            // -----------------------------------------------------------------
            function should__process_8bit() {
                return _process_8bit && ((_ex_background && !output_background) ||
                                        (_ex_color && !output_color));
            }
            // -----------------------------------------------------------------
            function process_8bit() {
                if (_ex_color && palette[num] && !output_color) {
                    output_color = palette[num];
                }
                if (_ex_background && palette[num] && !output_background) {
                    output_background = palette[num];
                }
                _process_8bit = false;
            }
            // -----------------------------------------------------------------
            for (var i in controls) {
                if (controls.hasOwnProperty(i)) {
                    num = parseInt(controls[i], 10);
                    if (_process_true_color > -1) {
                        process_true_color();
                    } else if (should__process_8bit()) {
                        process_8bit();
                    } else {
                        set_styles(num);
                    }
                }
            }
            if (state.reverse) {
                if (output_color || output_background) {
                    var tmp = output_background;
                    output_background = output_color;
                    output_color = tmp;
                } else {
                    output_color = 'black';
                    output_background = 'white';
                }
            }
            output_color = output_color || state.color;
            output_background = output_background || state.background;
            var colors, color, background;
            if (state.bold) {
                colors = $.terminal.ansi_colors.bold;
            } else if (state.faited) {
                colors = $.terminal.ansi_colors.faited;
            } else {
                colors = $.terminal.ansi_colors.normal;
            }
            if (typeof output_color !== 'undefined') {
                if (output_color.match(/^#/)) {
                    color = output_color;
                } else if (output_color === 'inherit') {
                    color = output_color;
                } else {
                    color = colors[output_color];
                }
                state.color = output_color;
            } else {
                color = colors['white'];
            }
            if (typeof output_background !== 'undefined') {
                if (output_background.match(/^#/)) { // already 8bit color #460
                    background = output_background;
                } else if (output_background === 'transparent') {
                    background = output_background;
                } else if (state.blink && ansi_art) {
                    background = $.terminal.ansi_colors.bold[output_background];
                } else {
                    // background is not changed by bold flag
                    background = $.terminal.ansi_colors.normal[output_background];
                }
                state.background = output_background;
            } else if (state.blink && ansi_art) {
                background = $.terminal.ansi_colors.bold['black'];
            }
            var ret = [styles.join(''), color, background];
            if (state.blink && !ansi_art) {
                ret.push('terminal-blink');
            }
            return ret;
        }
Swiss character set
ESC (=
Reference: http://vt100.net/docs/vt220-rm/table2-15.html