#!/usr/bin/perl -w # save and run as ./mysql_unicode_test.pl dbi:mysql:database=yourdb youruser yourpw use strict; use DBI; our $dbh= DBI->connect(@ARGV, { RaiseError => 1, mysql_enable_utf8 => 1 }) or die; $dbh->do("drop table if exists fifi"); $dbh->do("create table if not exists fifi(a varchar(200) character set utf8)"); our $insertsth= $dbh->prepare("insert into fifi values(?)"); our $teststr= join("", map { chr $_ } qw( 10 100 1000 10000 8888 9999 65530 65533 65536 70000 80000 90000 100000 9999 8888 )); $insertsth->execute($teststr); our $selsth= $dbh->prepare("select * from fifi"); $selsth->execute(); our ($teststr2)= $selsth->fetchrow_array; print join( " ", map { ord $_ } split //, $teststr2), "\n";