Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RhodiumToad/2b5feb7114f7a805a07a2e30b3b0c32f to your computer and use it in GitHub Desktop.
Save RhodiumToad/2b5feb7114f7a805a07a2e30b3b0c32f to your computer and use it in GitHub Desktop.
UTF8 test query
select * from yourtable t
where encode(convert_to(t::text,'SQL_ASCII'),'hex')
!~ '(?x)
^(?:(?:[0-7][0-9a-f])
|(?:(?:c[2-9a-f]|d[0-9a-f])
|e0[ab][0-9a-f]
|ed[89][0-9a-f]
|(?:(?:e[1-9abcef])
|f0[9ab][0-9a-f]
|f[1-3][89ab][0-9a-f]
|f48[0-9a-f]
)[89ab][0-9a-f]
)[89ab][0-9a-f]
)*$';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment