Leser: 24
$json = new JSON->allow_nonref->utf8(1)->decode($query->param('json'));
UPDATE `projekte`.`ab2_user_home` SET `street` = 'Beispiel Ä' WHERE `ab2_user_home`.`id` =1 AND CONVERT( `ab2_user_home`.`street` USING utf8 ) = 'Beispiel ä' LIMIT 1;
{ mysql_enable_utf8 => 1 }
1 2 3 4 5 6 7 8
if(!utf8::is_utf8($fieldvalue)) { croak qq{ Adressbook::User::Data->set_data() does not get a utf8 flagged fieldvalue. Died. } }
{ mysql_enable_utf8 => 1 }
1 2 3 4 5 6 7 8 9 10 11 12 13
my $mysql_config = $new_object->load_config(); use DBI; $database_handle_of{ident $new_object} = DBI->connect( "DBI:mysql:database=$mysql_config->{'table'}; host=$mysql_config->{'host'}; port=$mysql_config->{'port'};", $mysql_config->{'user'}, $mysql_config->{'password'}, { mysql_enable_utf8 => 1 } ) or croak $DBI::errstr; my $drh = DBI->install_driver("mysql");
Täststring wird zu Täststring
1
2
3
4
5
6
7
8
9
10
11
12
mysql> show create table data;
+-------+-----------------------------------------------------+
| Table | Create Table |
+-------+-----------------------------------------------------+
| data | CREATE TABLE `data` (
`id` int(11) NOT NULL auto_increment,
`key` varchar(255) default NULL,
`value` varchar(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
+-------+-----------------------------------------------------+
1 row in set (0.00 sec)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#!/usr/bin/env perl # Core Modules use strict; use warnings; use utf8; use open ':encoding(UTF-8)'; use open ':std'; # CPAN Modules use DBI; # Options my $host = 'localhost'; my $database = 'test'; my $user = 'root'; my $passwd = ''; my $options = { RaiseError => 1, AutoCommit => 1, mysql_enable_utf8 => 1 }; my $dsn = "dbi:mysql:database=$database"; # connect to database my $dbh = DBI->connect($dsn, $user, $passwd, $options); # insert statement my $insert_sql = q{ INSERT INTO data SET `key` = ?, `value` = ? }; my $insert = $dbh->prepare($insert_sql); # read all statement my $select_sql = q{ SELECT `id`, `key`, `value` FROM data }; my $select = $dbh->prepare($select_sql); # input some data $insert->execute('näme', 'dävid'); $insert->execute('wörld', 'föö'); $insert->execute('möp', 'müps'); # print all inserted $select->execute(); while ( my $data = $select->fetchrow_arrayref() ) { printf "id: %d key: %s value: %s\n", @$data; }
1
2
3
4
sidburn@sid:~/perl$ ./db.pl
id: 1 key: näme value: dävid
id: 2 key: wörld value: föö
id: 3 key: möp value: müps
1
2
3
4
5
6
7
8
9
10
11
12
mysql> SET NAMES utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM data;
+----+--------+--------+
| id | key | value |
+----+--------+--------+
| 1 | näme | dävid |
| 2 | wörld | föö |
| 3 | möp | müps |
+----+--------+--------+
3 rows in set (0.00 sec)
2009-05-20T12:01:25 rooootVielen Dank für deine Mühe.
Also wenn ich vor dem Eintragen in die DB noch mal ein utf8::decode davor hänge funktioniert es. Also ist es wohl wirklich 2 mal codiert. Ich muss mich jetzt nur auf die Suche machen, wo das passiert. Anregungen wo das üblicherweise sein könnte?