For anybody wondering, the likely origin of the invalid character is somebody using an Apple Ireland/UK keyboard layout where # is Option-3 (AltGr-3), and non-breaking space is Option-Space (AltGr-Space).
Unfortunately it is a bit of a hack that shells out to "file -i", but I'll take it over hours of frustration.
Such as UTF-8?