lists.zerezo.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

***BOGO*** Re: [Mingw-users] ANSI escape sequences problem



Bengt Werstén schreef:
-----Original Message-----
From: mingw-users-bounces@xxxxxxxxxxxxxxxxxxxxx [mailto:mingw-users-bounces@xxxxxxxxxxxxxxxxxxxxx] On Behalf Of JonY
Sent: den 24 juni 2008 09:02
To: MinGW Users List
Subject: Re: [Mingw-users] ANSI escape sequences problem

Bengt Werstén wrote:
Using the simple program:

#include <stdlib.h>
#include <stdio.h>

int main(void)
{
const unsigned char back[] = {0x1b, '[', 'D', '\0'};
printf("12%s34", back);
return 0;
}

It do not give the same result when executed from cygwin bash depending if
built using mingw or not.

$ gcc main.c
Results in printing 134 when run and this is expected since the escape
sequence should result in a cursor left.

$ gcc -mno-cygwin main.c
Results in 12←[D34 being printed when run but I would like it to have the
same result as above.

Is there anyway around this since I need to use MinGW with this
behavior? I have tried out output methods like write and putc but it is
still the same result.
This is due to the fact that the Windows console does not understand the escape sequence. This is not really a MinGW problem. Not too sure how to resolve it without resorting to 3rd party programs.
Hmm, does I not matter at all that I run both programs from the same bash shell in cygwin?
AFAIK the version compiled with Cygwin (i.e. *without* -mno-cygwin) uses a different I/O library which emulates the behaviour of a terminal that supports ANSI control sequences. The version compiled without Cygwin (i.e. *with* -mno-cygwin) links with Windows' native C library, which doesn't emulate a proper ANSI terminal in Windows' console, thus the difference. Thus the shell that you happen to use doesn't matter.

I expect that running the Cygwin version in Windows' native "dos-like" shell (cmd.exe) would give you the same behaviour.

Either way, this is mainly an educated guess, but you can test it like I mentioned above.

PS Please don't top-post.

--
Giel

Attachment: signature.asc
Description: OpenPGP digital signature

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users