Support ANSI terminal color escape sequences in XML?

时光怂恿深爱的人放手 提交于 2019-12-13 02:11:42

问题


I am using "termcolor" and "colored" for printing some colored words in my test script.

>>> from termcolor import colored
>>> result = colored("pass", "red")
>>> print result
pass ----> ("appears in red")
>>> result = '\033[1m' + result  + '\033[0m'
>>> print result
pass ------> ("appears in red and bold")

The above works fine on Mac and CentOS but fails to print it in red or bold in eclipse (on CentOS). It prints something like this "?[32mPASS?[0m" -- which does not help much..

I want to add that, the above text is seen on an XML file opened in eclipse. The encoding format probably has a role to play here. Right now I see "UTF-8" in the XML as encoding format.


回答1:


The issue is that unlike most terminals, the default Eclipse console does not know how to deal with the ANSI escape sequences that provide the color information.

There is however a plugin called ANSI Escape in Console available from the Eclipse marketplace that augments the standard Eclipse console to be able to deal with these ANSI color escape sequences:

http://marketplace.eclipse.org/content/ansi-escape-console#.U978fXV515Q

The plugin author's blog provides some more information:

http://mihai-nita.net/2013/06/03/eclipse-plugin-ansi-in-console/



来源:https://stackoverflow.com/questions/25111324/support-ansi-terminal-color-escape-sequences-in-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!