I'm not convinced that the non-ascii character in your code is actually utf-8 (at least not as represented here on this site). Replacing this with its named character (slightly different from Corion's example) I get this test script which passes fine on Linux (having first run mkdir a ü of course). YMMV with other OSes.

#!/usr/bin/perl use utf8; use strict; use warnings; use DBI; use Test::More; my @dbs = ('a/databaseTest1.db', "\N{LATIN SMALL LETTER U WITH DIAERESIS}/databaseTest2.db"); plan tests => 7 * @dbs; for my $db (@dbs) { dbt ($db) } exit; sub dbt { my $dbname = shift; my $dbh = DBI->connect("dbi:SQLite:$dbname", "", "", { RaiseError +=> 1, AutoCommit => 1, PrintError => 1 }); ok ($dbh, "Creating database $dbname"); ok ($dbh->do( "CREATE TABLE data ( ID INTEGER PRIMARY KEY, text, f +ilename)" ), "Created table data"); ok ($dbh->disconnect, "Disconnected from $dbname"); ok (-e $dbname, "Database file exists"); $dbh = DBI->connect("dbi:SQLite:$dbname", "", "", { RaiseError => +1, AutoCommit => 1, PrintError => 1 }); ok ($dbh, "Reconnected to database $dbname"); my $AllDbText_ref = $dbh->selectall_arrayref("SELECT filename FROM + data"); ok (defined $AllDbText_ref, "Results set obtained from $dbname"); ok ($dbh->disconnect, "Disconnected from $dbname"); }

You'll see that I've moved the operations into a subroutine to show that there aren't any differences (and to shorten it). Here's the output:

$ perl sqlt.pl 
1..14
ok 1 - Creating database a/databaseTest1.db
ok 2 - Created table data
ok 3 - Disconnected from a/databaseTest1.db
ok 4 - Database file exists
ok 5 - Reconnected to database a/databaseTest1.db
ok 6 - Results set obtained from a/databaseTest1.db
ok 7 - Disconnected from a/databaseTest1.db
ok 8 - Creating database ü/databaseTest2.db
ok 9 - Created table data
ok 10 - Disconnected from ü/databaseTest2.db
ok 11 - Database file exists
ok 12 - Reconnected to database ü/databaseTest2.db
ok 13 - Results set obtained from ü/databaseTest2.db
ok 14 - Disconnected from ü/databaseTest2.db

HTH, Hippo


In reply to Re: Connect SQLite with unicode directory by hippo
in thread Connect SQLite with unicode directory by IB2017

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.