SQL select to find UTF-8 chars (non-ascii) in Postgresql database.

I wanted to quickly find strings in a datbase with UTF-8 chars in them to ensure they are being input’ed and displayed properly.

I came up with the following two statements that seem to work equivalently:

select col from tablename where col ~ '[^[:ascii:]]';

and

select col from tablename where col ~ '[\x80-\10FFFF]';

Similar variations will likely work in other database systems as well.

Facebook Comments

comments

Posted in post