On line 345 of utf.d (std.utf) we can find: throw new UtfException("4invalid UTF-8 sequence", i); The "4" seems to be a typo (which makes for ugly error messages:)
It's not a typo: within std.utf you'll find "Ninvalid UTF-8 sequence", where N ranges from 1 to 5. 4 is just the most common, because it's in the decode() method which is used by std.format.doFormat, which, in turn, is used by the writef family. I agree, however, that it makes for ugly error messages, and it does appear a lot like a typo, so I'll leave the bug open - just renamed.
Ok, changing the message seems a fine choice to me. Perhaps "invalid UTF-8 sequence at byte X"?
I replaced the culprit with: throw new UtfException(text("dchar decode(in char[], ref size_t): " "Invalid UTF-8 sequence ", cast(const ubyte[]) s, " around index ", i)); http://www.dsource.org/projects/phobos/changeset/1999