It would be useful to have a function that removes all ansi control characters from a given string.
There are (at least two) use-cases for something like this:
If you have a string that have already been styled and need to provide it to some consumer that don't support ansi (a file, over the network, terminal without ansi-support).
If you have a string that have already beed styled and need to calculate the length in terms of visible characters.
Here is an example implementation (which probably doesn't cover all valid ansi control characters) that takes the rather inefficient approach of scanning the the characters of the string dropping everything between and "m". I probably possible to use a regexp to achieve the same thing in a more efficient way.
It would be useful to have a function that removes all ansi control characters from a given string.
There are (at least two) use-cases for something like this:
Here is an example implementation (which probably doesn't cover all valid ansi control characters) that takes the rather inefficient approach of scanning the the characters of the string dropping everything between and "m". I probably possible to use a regexp to achieve the same thing in a more efficient way.