java vs c, escape sequences

Barry Kelly bkelly.ie@gmail.com
Sat Sep 13 16:46:00 GMT 2008


rick271828 wrote:

> Can anybody please explain why the c code:
>     printf("%c[H%c[J",27,27); clears my cygwin console as expected, but the
> Java code:
> 
>  System.out.print("\033[2J\033[H");
> 
> displays a back arrow instead on interpreting the escape character?

It's because you are not running the program with stdout attached to a
terminal or terminal emulator. Probably, you are running in a console
window.

Cygwin can emulate a terminal in a console window for programs that do
all I/O through it, but for third-party applications, like Sun java, it
cannot.

Run the application in rxvt and it works as expected.

-- Barry

-- 
http://barrkel.blogspot.com/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list