Re: Problem with strlen and string containing color codes

From: Chris Gilbert (chris@buzzbee.freeserve.co.uk)
Date: 08/27/99


Chuck Carson wrote:
>
> I am tring to print a string such in the following manner:
>
> sprintf(buf, "%-50s %d\r\n", string, var);
>
> However, if the string contains color codes, the second
> argument does not line up correctly, ie. sprintf does not
> display 50 spaces before the second var is printed.

Not really, you could write a func to strip all the colour out of the
string, otherwise it'll be kind of random.  The colour is parsed later,
so the 2 chars that the colour code takes up will get expanded to 5 or
6.

> How can I force this to keep the spacing correct?

sprintf is doing the right thing, it's got no concept of the colour
codes, they're just more bytes to shift around.   I'd say the easiest
thing is to just strip the colours codes out.  The other possibilty is
to re-write sprintf ;)

Chris


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST