Guest User

Untitled

a guest
Sep 8th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. use strict;
  2. use DBI;
  3.  
  4. # CREATE TABLE `t` (
  5. # `a` text
  6. # ) DEFAULT CHARSET=utf8;
  7.  
  8. my $user = 'root';
  9. my $pass = '';
  10.  
  11. my $dbh = DBI->connect(
  12. 'DBI:mysql:test;host=localhost',
  13. $user,
  14. $pass,
  15. { mysql_enable_utf8 => 1 });
  16.  
  17. my $str = "before\x{1f3c4}after";
  18.  
  19. my $sth = $dbh->prepare('INSERT INTO t VALUES (?)');
  20. $sth->execute($str);
  21.  
  22. # mysql> select a, length(a), char_length(a) from t;
  23. # +--------+-----------+----------------+
  24. # | a | length(a) | char_length(a) |
  25. # +--------+-----------+----------------+
  26. # | before | 6 | 6 |
  27. # +--------+-----------+----------------+
  28. # 1 row in set (0.01 sec)
Add Comment
Please, Sign In to add comment