Refactor the code that writes the a message segment to reduce code duplication.
Refactor the code that writes the a message segment to reduce code duplication.

Also simplify the code around the check for escaped character.

AlexGhiondea/OutputColorizer,AlexGhiondea/OutputColorizer