> eval string x = "%^BOLD%^%^YELLOW%^asdf%^RESET%^"; string y = strip_colours(x); int z = strlen(x); int zz = strlen(y); return ({ z, zz });
Result = ({ 31, 19 })
> eval string x = "%^BOLD%^%^YELLOW%^asdf%^RED%^"; string y = strip_colours(x); int z = strlen(x); int zz = strlen(y); return ({ z, zz });
Result = ({ 29, 4 })
Interesting.
> eval string x = "%^BOLD%^%^YELLOW%^asdf%^RESET%^"; string y = strip_colours(x); int z = strlen(y); int i; for( i = 0; i < z; i++ ) { write(sprintf("%02d %02x", i, y[i])); }
00 61
01 73
02 64
03 66
04 1b
05 5b
06 34
07 39
08 3b
09 34
10 39
11 6d
12 1b
13 5b
14 30
15 3b
16 31
17 30
18 6d
Result = 0
Now, are you ready to be terrified? Here's a horrible thing that seems to be the result of LPC's type-by-value rather than type-by-variable...
> eval string x = "%^BOLD%^%^YELLOW%^asdf%^RESET%^"; string y = strip_colours(x); int z = strlen(y); int i; for( i = 0; i < z; i++ ) { write(sprintf("%02d %c", i, y[i])); }
00 a
01 s
02 d
03 f
04 [0m
05 [
06 4
07 9
08 ;
09 4
10 9
11 m
12 [0m
13 [
14 0
15 ;
16 1
17 0
18 m
Result = 0
Note that I'm using sprintf's %c token to see the individual character values.... but in cases where the value is an ESC, sprintf's %c ends up seeing the rest of that string!
Oddly enough, this explains a strange phenomenon in my i3 logs. For ages now, I've been trying to figure out where the weird escape sequence of ESC[49;49m was coming from. I couldn't ever find it in the source of anything, but it shows up in EMOTE strings over I3.
Wodan? Cratylus? Any ideas about this? I'm at a loss, since while I'm using Dead Souls, I'm also using a customized color system. The odds of this hitting both me AND someone using Nightmare IV are pretty slim, unless it's a bug introduced in the driver's terminal_color() changes, or a very LONG standing bug from the dark ages that's in EVERY nightmare based mudlib out there...