C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ANSI escapes in text

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
yeknom@gmail.com
Guest





PostPosted: Tue Aug 16, 2005 2:41 pm    Post subject: ANSI escapes in text Reply with quote



Is there a good way of filtering/recognizing standard ANSI escape
characters in a text file using c++? I thought about using regexp's but
I cannot find a regexp expression to define ANSI Escapes.

thanks


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
tony_in_da_uk@yahoo.co.uk
Guest





PostPosted: Wed Aug 17, 2005 5:27 pm    Post subject: Re: ANSI escapes in text Reply with quote



I think the lack of response here is largely due to the lack of detail
in your query. Do you want to throw away such sequences, or extract
their parameters for processing? Do you just want the sequences you'd
find supported by MS-DOS ansi.sys? I don't personally know (or care -
sorry)whether the ANSI publishes standards for vt100, vt220 or other
protocols. Anyway, ansi.sys-type escape sequences are so few that
parsing them is trivial, especially if you don't care about the more
obscure ones embedding double-quotes strings.

You could create your own regexp expression in a few minutes, but again
it will vary depending on whether you need to select and return the
parameter subexpressions, and the exact syntax your regexp library
provides for doing so. You could equally use boost::spirit or write
something from scratch. If you end up doing the latter, I'd suggest
when you find an escape, scan forward until you find an alphabetic
character, while skipping over any double-quoted strings. You can then
use the final character to go back and extract the arguments, perhaps
switching on that final character to select a sscanf() format string
matching the possible parameters. Easier still, but slower, ditch the
`scan forward to find the final character' business and code the whole
thing as an if/else list of sscanf()s.

Tony


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.