Issue
I have a file with a bunch of terminal logs captured with the screen
utility. Here's a snippet:
[A[0m[27m[24m[J[34m~[39m
(base) [38;5;242mbase[39m [35m❯[39m ]133;B[K[?1l>[?2004l
[A[0m[27m[24m[J[34m~[39m
etc etc etc.
The output is full of ANSI escape codes, \r, \n, etc. Yet my terminal manages to render it all quite nicely, and I imagine I ought to be able to as well. I have found some libraries that convert ANSI codes to HTML, but I don't think they handle any of the other escaping.
I still feel like someone must have solved this problem, somehow, before me. Is there an easy way to do this?
Solution
There're many nice answers at an old SE post Depending on your environment, you may find some other packages to
- NodeJS at github
- another JS
- Python at github
- C at github (already mentioned)
- PERL (also mentioned)
- sh+AWK at github
- and certainly much more.
Answered By - gildux Answer Checked By - Robin (WPSolving Admin)