Subj : printf and color codes
To : Nightfox
From : MCMLXXIX
Date : Mon Jan 21 2013 11:29 am
Re: printf and color codes
By: Nightfox to Mro on Sun Jan 20 2013 21:50:02
> Re: printf and color codes
> By: Mro to Nightfox on Sun Jan 20 2013 21:43:04
>
> >> non-printable character subtracts 1 from the field length when the
> >> string is printed out. CTRL-A color codes have this effect when used
> >> with printf.
>
> Mr> i'm pretty sure that's intentional and certainly seems like it should b
>
> It's not what I would expect. If you specify a field length for printf(), i
> should fill that entire field up to that length. Otherwise, the results can
> unexpected and ugly. The main uses for specifying a field length are to ali
> text and filling a space when overwriting existing text on the screen. I wo
> expect printf() to only count visible/printable characters in the length of
> string you give it.
>
> Mr> who's name or other variable would have color codes in it, though?
>
> Anything where color is desired.. :P
>
I think you're right about this.. if printf is able to handle ctrl-A codes it
likely should be able to format them correctly.. you can work around it though.
var diff = str.length - console.strlen(str);
printf("%-*s",25+diff,str);