Patch isvalid to properly handle unicode data. Fixes #1.