Add preventive type checking.

Ensure data is unicode otherwise, it will segv.