You need to tell Perl and SQLite that you're using UTF-8:
#!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };
use utf8; # Source code contains non-ASCII UTF-8 characters.
use open IO => ':encoding(UTF-8)', ':std'; # Output should be UTF-8 e
+ncoded.
use DBI;
use DBD::SQLite::Constants ':dbd_sqlite_string_mode'; # A constant us
+ed below.
my $dbh = 'DBI'->connect('dbi:SQLite:dbname=:memory:', "", "", {
# This tells the db driver to use Unicode.
sqlite_string_mode => DBD_SQLITE_STRING_MODE_UNICODE_STRICT
});
$dbh->do('CREATE TABLE t1 (temperature INT, degree TEXT)');
my $insert = $dbh->prepare(
'INSERT INTO t1 (temperature, degree) VALUES (?, ?)');
$insert->execute(10, '°C');
$insert->execute(80, '°F');
my $select = $dbh->prepare('SELECT * FROM t1');
$select->execute;
while (my @row = $select->fetchrow_array) {
say "@row";
}
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
|