I am having a MySQL table where some rows are correctly UTF8, some are inserted as ISO. I need to convert them into UTF8.
Eg.
Hahnemühle
Hahnemühle
How can I convert only rows from ISO-8859-1 to UTF8?
Here's what I have tried. I'm checking if iso-to-utf gives valid result:
# create table
create table tmp1 (
txt varchar(100)
);
# insert data
insert into tmp1 values ('Hahnemühle');
insert into tmp1 values ('Hahnemühle');
# convert
update tmp1
set txt=convert(cast(convert(txt using latin1) as binary) using utf8)
where convert(cast(convert(txt using latin1) as binary) using utf8) is not null;
It gives me: [HY000][1300] Invalid utf8 character string: '...'
Which is weird because result of:
select txt
from tmp1
where convert(cast(convert(txt using latin1) as binary) using utf8) is not null
is:
Hahnemühle