Return NULL for invalid chars

This point will never be reached, thanks to throwing an exception, but
a return value is needed to shut the compiler up
Merge pull request #194 from karelia/master

Return NULL for invalid chars