Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: converting some rows from utf-8 to iso-8859-1

From: Ken Peng <kenpeng(at)fastmail.fm>
Date: Thu Aug 30 2007 - 21:31:05 EDT

On Thu, 30 Aug 2007 11:41:14 +0200, "Olav Mørkrid" <olav.morkrid@gmail.com> said:
> if a table column is supposed to contain text in iso-8859-1, but utf-8
> encoding have snuck in on a few rows by mistake, how are these rows
> converted into iso-8859-1?
>
> what i am looking for is something like this:
>
> update mytable set mycolumn = utf8toiso88591(mycolumn) where id
> between 500 and 600;
>

I don't know if mysql has this charset converting routine. But you can do it by application scripts,ie,in perl you can convert them by,

use Encode;
my $iso_str = encode('iso-8859-1',decode('utf8',$utf8_str));

first you select utf8 string from db one by one and store it to $utf8_str,then use the function above to be converted to iso-8859-1,then insert it again to mysql.

-- 
  Ken Peng
  kenpeng@fastmail.fm

-- 
http://www.fastmail.fm - Accessible with your email software
                          or over the web


-- 
MySQL General Mailing List
For list archives: 
http://lists.mysql.com/mysql
To unsubscribe:    
http://lists.mysql.com/mysql?unsub=lists@pantek.com
Received on Thu Aug 30 21:33:53 2007

This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 10:08:13 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library