Thursday, May 7, 2009

Find non-ascii chars in mysql

How can you tell whether a non-ascii character is sneaking into a field that should not contain any such characters?

Cast the field to ascii and see if it's any different:
select item_id, uri from items where convert(uri using ascii) <> uri;

Of course, you can/should preclude such a possibility by changing the character set of the field to ascii.

No comments: