Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use DBI;
- # CREATE TABLE `t` (
- # `a` text
- # ) DEFAULT CHARSET=utf8;
- my $user = 'root';
- my $pass = '';
- my $dbh = DBI->connect(
- 'DBI:mysql:test;host=localhost',
- $user,
- $pass,
- { mysql_enable_utf8 => 1 });
- my $str = "before\x{1f3c4}after";
- my $sth = $dbh->prepare('INSERT INTO t VALUES (?)');
- $sth->execute($str);
- # mysql> select a, length(a), char_length(a) from t;
- # +--------+-----------+----------------+
- # | a | length(a) | char_length(a) |
- # +--------+-----------+----------------+
- # | before | 6 | 6 |
- # +--------+-----------+----------------+
- # 1 row in set (0.01 sec)
Add Comment
Please, Sign In to add comment