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]
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|