Nothing against the code, but there are some non-printable characters that will not show up in the above script, and mIRC.net has a complete display of all of the $chr codes including the non-printable ones, such as the codes for colour, bold, underline, Line feed, carriage return, etc.
Unfortunately their site is down at the moment so I'm unable to post a reference link to the actual list.
Here's the URL if anyone is interested http://www.mirc.net/ascii.php