Working on my latest pet-project (web irc client and server using comet, ajax and a newly written async php socket daemon which can hande the many hanging iframe get’s aka comet connections) i’m trying to offload as much of the logic as posible to the client side.. The more work the client has to do, the easier and more scalable the server will be.
I didn’t want the non-blocking server to constantly choking down every text message that’s being send to the (potentially hundreds off-) clients, so i implimented the mIRC style and color parsing in javascript, so the individual web browsers can deal with this, and offload the server..
The basics of it are relatively easy, just parse thru the string one character at a time, and if a mIRC control code is found, modify the string accordingly (apply either a color, underline, bold or reverse). An article explaining the codes in mIRC can be found here
The code can be found here: mIRC coloring in javascript

Hi Chris,
thanks for this piece of code, I’ve ported it to PHP and will use it in the new TopicSpy.
-arne
Hey Arne,
Glad to hear its of use to someone
I’ve spoted some errors on your script.
One is you have newtext instead of newText on line 32, the second you have }, on line 103 where it should be };
Besides that, great script
It will probably be used on a irc logging network app I’m using….
You’ve also forgot two break in the switch =).