#!/usr/bin/env perl use v5.40; # brian d foy recommends using these settings # (https://stackoverflow.com/a/47946606/522385): # (1) recognize UTF-8 in this source code: use utf8; # (2) do the right things for writing and reading UTF-8, including to STD*: use open qw(:std :encoding(UTF-8)); my $utf8_text1 = "Åke Lindström"; # contains UTF8 chars: say "A variable set to a UTF8 literal within perl program"; show ($utf8_text1); use DBI; my $dbh = DBI->connect( "dbi:SQLite:dbname=:memory:", "", "", { RaiseError => 1, AutoCommit => 1 } ); $dbh->do('CREATE TABLE names (name_id CHAR PRIMARY KEY, name CHAR)'); $dbh->do(qq{INSERT INTO names VALUES("nm0512537", "$utf8_text1")}); my $aoa_ref = $dbh->selectall_arrayref( q{SELECT name FROM names WHERE name_id="nm0512537"} ); say "\nUTF-8 text stored in, and retrieved from, sqlite DB:"; show($aoa_ref->[0][0]); sub show($str) { say "Binary: ", join ' ', (unpack "H*", $str) =~ m/../g ; say "Text>STDOUT: $str"; }