Encoding issues.

--0015174c128e5f7845048db3bacb
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi Guys,

I just wrote a script that retrieves some records from a MYSQL database.
These records contain a lot of the special characters from the French
language. I need a way to decode these characters properly before sending
them on to a third party.

For example, retrieving this from the database:

"La C=EF=BF=BDte d'Ivoire a battu hier l'Italie en match amical 1-0. But de=
Kolo
Tour=EF=BF=BD (55)
Les Elephants pr=EF=BF=BDparent les =EF=BF=BDliminatoires de la CAN 2012."

And then send it on without all those =EF=BF=BD characters which are in act=
ual fact
special characters from the french language.

Any ideas? Anyone?

Kwaku.

--0015174c128e5f7845048db3bacb--
Kwaku Addo Ofori [ Fr, 13 August 2010 14:35 ] [ ID #2046016 ]

Re: Encoding issues.

On 13 August 2010 13:35, Kwaku Addo Ofori <kayofori [at] gmail.com> wrote:
> Hi Guys,
>
> I just wrote a script that retrieves some records from a MYSQL database.
> These records contain a lot of the special characters from the French
> language. I need a way to decode these characters properly before sending
> them on to a third party.
>
> For example, retrieving this from the database:
>
> "La C=EF=BF=BDte d'Ivoire a battu hier l'Italie en match amical 1-0. But =
de Kolo
> Tour=EF=BF=BD (55)
> Les Elephants pr=EF=BF=BDparent les =EF=BF=BDliminatoires de la CAN 2012.=
"
>
> And then send it on without all those =EF=BF=BD characters which are in a=
ctual fact
> special characters from the french language.
>
> Any ideas? Anyone?

You will need to use the Encode[1] module and it's decode function.
The trick is working out what encoding the data is in. You will need
to check the settings on your MySQL database table(s) to see what
encoding it's storing the strings in but sometimes it's not as simple
as that. That why there is the Text::GuessEncoding[2] module because
data is not always stored in the same encoding that arrived in.

Good luck,
Dp.

[1] http://search.cpan.org/~dankogai/Encode-2.39/Encode.pm
[2] http://search.cpan.org/~jnw/Text-GuessEncoding-0.07/GuessEnc oding.pm

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
dermot [ Fr, 13 August 2010 15:58 ] [ ID #2046017 ]
Perl » gmane.comp.lang.perl.beginners » Encoding issues.

Vorheriges Thema: interpolation problem in emacspipe.pl script from emacswiki
Nächstes Thema: next in foreach loop