使用perl,我尝试从一个默认字符集为Latin1_General_CI_AS的SQLSERVER数据库中读取一些记录
这些记录有一些特殊的字符(例如:àèò)
当我提取这些记录时,perl输出不会显示这些特殊字符。
我尝试了编码/解码函数,但没有成功...
use DBI;
# DBD::ADO
$dsn = "Provider=sqloledb;Trusted Connection=yes;";
$dsn .= "Server=$host;Database=$database";
my $dbh = DBI->connect("dbi:ADO:$dsn", $user, $auth,
{ RaiseError => 1, AutoCommit => 1}
) || die "Database connection not made: $DBI::errstr";
$sql = "select idnews, titolo from news where idnews>$ultimoidinserito";
$sth = $dbh->prepare($sql);
$sth->execute
or die "SQL Error: $DBI::errstr\n";
while(@row = $sth->fetchrow_array)
{
$titolo=lc($row[1]);
$idnews=$row[0];
print "$titolo\n";
}预计会有一些记录:
Eurolega la finale saràCSKA-Efes
未来的Allegri生态鸽puó和andare
获得的结果:
Eurolega la finale sarαCSKA-Efes
未来的Allegri生态鸽pu≥和
发布于 2020-02-28 15:28:53
my $reportJson = to_json($data,{ pretty => 1})使用perl“漂亮”,一切看起来都很好。
https://stackoverflow.com/questions/56194799
复制相似问题