The output created by the diff function can include invalid utf-8 characters.
e.g.
http://wiki.splitbrain.org/plugin:highlight?rev=1155731333&do=diff
The '�' (Firefox) or '?' (IE6) at the end of many of the diff context snippets are the browser's rendering of the invalid character. I believe them to be the byte 0xA0 occuring which may occur at the end of the snippet.