Click here to get back home

Notes on unicode/utf8, CGI, DBI, mysql

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Notes on unicode/utf8, CGI, DBI, mysql kbin 03-06-2008
Posted by kbin on March 6, 2008, 5:18 am
Please log in for more thread options

I've written a small tutorial/guide on some of the issues I've come
across when trying to use unicode/utf8 in my LAMP stack and thought
I'd share them.

http://kbinstuff.googlepages.com/perl%2Cunicodeutf8%2Ccgi.pm%2Capache%2Cmod_perla

I hope you will find it useful and please provide me with feedback.

--Kalle



Posted by Joost Diepenmaat on March 6, 2008, 1:35 pm
Please log in for more thread options

> Good idea to sumarize possible problems - good page.
> I can mention only that you can use this too
>
> my $dbh = DBI->connect( <parameters>);
> $dbh->do( "SET NAMES utf8");

That by itself won't guarantee that your data will be correctly
handled. DBD::mysql provides the mysql_enable_utf8 option for a
reason. You do need at least DBD::mysql 4.004 for it to work more or
less correctly, though.

To the original poster: don't worry too much about the experimental
status of the option. It might some day go away (IMO not very likely,
though) but it's the best method today for getting reasonable unicode
behaviour out of DBD::mysql. At worst, you may have to remove the option
some time in the future, but the behaviour it enables is likely to stay.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

Posted by Joost Diepenmaat on March 6, 2008, 1:49 pm
Please log in for more thread options

> I've written a small tutorial/guide on some of the issues I've come
> across when trying to use unicode/utf8 in my LAMP stack and thought
> I'd share them.
>
>
http://kbinstuff.googlepages.com/perl%2Cunicodeutf8%2Ccgi.pm%2Capache%2Cmod_perla
>
> I hope you will find it useful and please provide me with feedback.

Nice work. There are still some issues with straight DBD::mysql, even
using the lastest versions and using the enable_utf8 option. I've made
some remarks on that in reply to this post on perlmonks:

http://perlmonks.org/?node_id=620803

The most important bug/missing feature still outstanding is:
http://rt.cpan.org/Public/Bug/Display.html?id=25590

Basically, this means that data inserted into UTF8 columns *must* be
utf-8 encoded (note that you *must not* encode non-UTF8 column
data!). See the perlmonks link for more info.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

Similar ThreadsPosted
My own handy Pocket Reference notes August 16, 2004, 5:45 pm
My own handy Pocket Reference notes (please share your own also) August 11, 2004, 6:52 pm
Msql-Mysql-modules: unable to find my mySQL 'include' dir March 4, 2005, 2:57 am
can't install DBD::mysql - missing mysql.h? November 30, 2004, 4:39 pm
DBD:mysql doesn't read mysql option file /etc/my.cnf file January 27, 2005, 11:19 pm
net::mysql January 16, 2006, 3:33 pm
Perl to MySQL? December 9, 2004, 3:29 pm
mysql: doable? January 25, 2005, 6:19 pm
Using MySQL with Perl February 3, 2005, 6:31 pm
mysql list all db name February 28, 2005, 11:23 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap