On 13 August 2010 13:35, Kwaku Addo Ofori <[email protected]> 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�te d'Ivoire a battu hier l'Italie en match amical 1-0. But de Kolo > Tour� (55) > Les Elephants pr�parent les �liminatoires de la CAN 2012." > > And then send it on without all those � characters which are in actual 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/GuessEncoding.pm -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
