How can I go about detecting IRC color codes within a String?
Here’s what I’ve tried:
int length = message.length();
ArrayList<Object> buffer = new ArrayList<Object>();
for (int i = 0; i < length; i++) {
char ch = message.charAt(i);
if (Character.isDefined(ch) && !Character.isLetter(ch)) {
Methods.log("val " + (int) ch);//Attempt logging the irc color value
} else {
buffer.add(ch);
}
}
However this failed. I’m writing an IRC client for my grade 11 programming class and I figured colors would be a cool feature to add.
The IRC colors are “specified” by mIRC — it’s complicated, and not all clients interpret the specification the same way — but you’re looking for the
^C“control character” (0x03) followed by digits that describe which specific foreground and background colors to use.Once you’ve found them in the stream of text you’ll need to figure out how to change the text color on your text widgets and remember to set the text back to normal before the next message is output.