Subject: | UTF8 strings have no utf8 flag set |
I can't clearly figure out if is dupe, seems like it is not. Others were not touched for years already.
Unicode strings has no utf8 flag set. So strings are encoded in utf8, but there is no utf8 flag.
I've created a unicode db and a table in it, see dbinit.sql for mo detail.
Repro script in attach.
All strings are valid utf8 strings but without utf flag. These strings go to output incorrectly unless I update it myself.
Note: all utf8 flags set for outputs, etc...
perl version: v5.10.1, build 1006 [291086]
DBD-mysql: 4.011
DBI: 1.609
OS: Windows 7 32bit [Version 6.1.7600]
MySQL: 5.1.37 win32 on localhost
Unicode strings has no utf8 flag set. So strings are encoded in utf8, but there is no utf8 flag.
I've created a unicode db and a table in it, see dbinit.sql for mo detail.
Repro script in attach.
All strings are valid utf8 strings but without utf flag. These strings go to output incorrectly unless I update it myself.
Note: all utf8 flags set for outputs, etc...
perl version: v5.10.1, build 1006 [291086]
DBD-mysql: 4.011
DBI: 1.609
OS: Windows 7 32bit [Version 6.1.7600]
MySQL: 5.1.37 win32 on localhost
Subject: | dbinit.sql |
Message body not shown because it is not plain text.
Subject: | repro.pl |
use Data::Dumper;
use strict;
use DBI;
use utf8;
use Encode;
binmode STDOUT, ":utf8";
binmode STDIN, ":utf8";
my ($host, $port, $database, $user, $password, $rise) = ('localhost','3306','flights','root','itsme');
my $dsn = "DBI:mysql:host=$host;port=$port;".
"database=$database;".
"mysql_compression=1;".
"mysql_client_found_rows=1;".
"mysql_auto_reconnect=1;".
"mysql_enable_utf8=1;";
my $dbh = DBI->connect(
$dsn,
$user,
$password,
{
RaiseError => 1,
}
);
$dbh->do("SET character_set_client = utf8;");
$dbh->do("SET character_set_connection = utf8;");
$dbh->do("SET character_set_results = utf8;");
my $query = $dbh->prepare("SELECT * FROM countries");
$query->execute();
my $data = $query->fetchall_arrayref();
foreach my $str (@$data)
{
foreach my $val (@$str)
{
print ("Value: $val, it is ".(utf8::is_utf8($val)?"":"non-")."utf8 string, and ".(utf8::valid($str)?"":"not")." valid<br>\n");
Encode::_utf8_on($val);
print ("Value: $val, it is ".(utf8::is_utf8($val)?"":"non-")."utf8 string, and ".(utf8::valid($str)?"":"not")." valid<br>\n");
}
}
$query->finish();
$dbh->disconnect();
return $data;