All in all, getting it right, and compatible with what's out in the world, is quite a task. Many of us end up with entire DEC VT state machines. Because it turns out that it's perfectly legitimate to emit some C0 control characters in the middle of a control sequence. I kid you not.