handle control characters
I need handle control characters in my program.
this code is a simple pipe: Code:
#include <stdio.h> ls --color | ./mypipe colored text will be display. how can I Ignore escape sequences? |
use ls --color=never
your program could filter the escape-sequences, but that wouldn't be easy, because there are many different espace-sequences. See man 5 terminfo for a start. |
"--color" is equivalent to "--color=always". If you use "--color=auto" instead it won't insert escape sequences when the output is a pipe or file, but will add them when it detects a raw terminal.
If you have to code it, however, a simple regular expression like "\033[[][0-9;]+m" can strip out all the color codes, at least. But as NevemTeve said, it would have to be much more complex to capture all of the possible ansi escape sequences. |
All times are GMT -5. The time now is 11:28 PM. |