Some characters will cause mIRC to not use UTF-8 when displaying text. That's most likely your problem. You can use $utfencode() around the character(s) that are causing the problem or just not include those in the output. Note that the actual unicode characters are NOT what you want to use $utfencode on. It would be something like « or ». If those are in a line with unicode, the unicode will not display properly unless you use $utfencode on those characters.