Skip to content

Instantly share code, notes, and snippets.

@danielholmstrom
danielholmstrom / fix_double_encoded_utf8.example.sql
Created October 5, 2011 10:53
Fix double encoded UTF-8 in mysql with an SQL-query.
-- Example of how to fix double encoded UTF-8 in mysql with a single mysql query.
-- This example assumes that the data has been inserted with NAMES=latin1.
--
-- XXX: Do not rely on this to work without testing it. XXX
--
-- XXX: If this is run on a column with a UNIQUE index and the COLLATE is
-- case-insensitive this might fail. The reason for this is that double-encoded
-- upper and lower case chars are considered different but when encoded correctly
-- they will be considered the same.