Also, the way color codes are handled behind-the-scenes should make any sensible programmer cry in pain.
==>echo("\c1\c2\c3\c4\c5\c6\c7\c8\cr\cp\co" $= "\x02\x03\x04\x05\x06\x07\x0B\x0C\x0F\x10\x11");
1
Yes, you read that right. The color codes OVERWRITE the following ASCII codes: 0x02 - 0x07, 0x0B, 0x0C, and 0x0F - 0x11.
You can't compare against \c0 like this, so I can only assume it's 0x01, but that's how the rest are represented.
<rant>"But it's just breaking archaic control characters no one —"
NO. If you're going to implement ASCII, you implement loving ASCII.
If you want to have control characters:
- have it stored in text form,1
- implement Unicode and use the Private Use Area as your control character,
- or make your own character encoding and use that instead.
</rant>1echo(getSubStr("<color:FF800080>", 1, 5));