但是為什麼我 db 裡面明明存 utf-8 讀出來卻不是呢? DBI::SQLite 說道..
If the attribute所以只要確定 db 裡面是存著 utf-8 的資料,只要再連線時設定好 sqlite_unicode,sqlite 的 DBI 會幫你把 utf-8 flag turn on:$dbh->{sqlite_unicode}
is set, strings coming from the database and passed to the collation function will be properly tagged with the utf8 flag; but this only works if thesqlite_unicode
attribute is set before the first call to a perl collation sequence . The recommended way to activate unicode is to set the parameter at connection time :
當然,總是有一些比較my $dbh = DBI->connect( "dbi:SQLite:dbname=foo", "", "", { RaiseError => 1, sqlite_unicode => 1, } );
沒有留言:
張貼留言