如何使用Perl的DBI处理unicode? [英] How can I handle unicode with Perl's DBI?

查看:81
本文介绍了如何使用Perl的DBI处理unicode?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 delicious-to -wp perl脚本可以工作,但可以提供所有怪异字符甚至怪异的输出。
因此,我尝试了

My delicious-to-wp perl script works but gives for all "weird" characters even weirder output. So I tried

$description = decode_utf8( $description ); 

但这没什么区别。我想例如上线变成上线而不是上线如何在Perl中处理unicode,以便它起作用?

but that doesnt make a difference. I would like e.g. "go live" to become "go live" and not “go live†How can I handle unicode in Perl so that this works?

更新:我发现了问题是要设置我必须在Perl中设置的DBI的utf:

UPDATE: I found the problem was to set utf of DBI I had to set in Perl:

my $sql = qq{SET NAMES 'utf8';};
$dbh->do($sql);

那是我必须设置的部分,比较棘手。谢谢!

That was the part that I had to set, tricky. Thanks!

推荐答案

它可能与Perl无关。检查并确保在相关的MySQL表列中使用的是UTF编码。

It may have nothing to do with Perl. Check to make sure you're using UTF encodings in the pertinent MySQL table columns.

这篇关于如何使用Perl的DBI处理unicode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆