PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > converting some rows from utf-8 to iso-8859-1
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
converting some rows from utf-8 to iso-8859-1

Réponse
 
LinkBack Outils de la discussion
Vieux 30/08/2007, 10h41   #1
Olav Mørkrid
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut converting some rows from utf-8 to iso-8859-1

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;
  Réponse avec citation
Vieux 31/08/2007, 02h31   #2
Ken Peng
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: converting some rows from utf-8 to iso-8859-1


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

  Réponse avec citation
Vieux 31/08/2007, 09h31   #3
Olav Mørkrid
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: converting some rows from utf-8 to iso-8859-1

yep, thru php it's easy: just do a utf8_decode($value). but is it
possible directly from the mysql command line.

On 31/08/2007, Ken Peng <kenpeng@fastmail.fm> wrote:
>
> 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
>
>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h42.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13645 seconds with 11 queries