Sanitizer handles invalid utf-8 characters gracefully

The sanitizer would fail if an invalid utf-8 character was passed along.

//cc @libo @vkmita @ggrossman