这个太有意思了 真没想到perl的内部字符形式就是这样存储的
在 2011年8月29日 下午5:41,cnhack TNT <[email protected]>写道: > 介个.... UTF8 环境下直接用双引号就好了: > > $string = "\347\234\213\346\235\245"; > print $string; > > win 系统下用 Encode 转码一下: > use Encode; > $string = decode_utf8("\347\234\213\346\235\245"); > print encode("gbk", $string); > > :-) > > > 2011/8/29 Phillip Huang <[email protected]> > >> 非常感谢! >> >> >> >> 2011/8/29 Achilles Xu <[email protected]> >> >>> my $x = "\\347\\234\\213\\346\\235\\245"; >>> >>> my @octs = split /\\/, $x; >>> >>> my @ints; >>> >>> for my $oct (@octs) { >>> $oct = "0" . $oct; >>> push @ints, oct($oct); >>> } >>> >>> my $str = ""; >>> for my $int (@ints) { >>> $str .= chr($int); >>> } >>> >>> print $str, "\n"; >>> >>> 在我的机器上测试输出成功。终端编码是utf-8. >>> >>> 在 2011年8月29日 下午3:10,Phillip Huang <[email protected]>写道: >>> >>>> 各位, >>>> >>>> 我得到一组八进制转码的 UTF-8 >>>> >>>> \347\234\213\346\235\245\ >>>> >>>> 请问有没有什么办法(perl脚本)将其转换为中文? >>>> >>>> PS: 我用了一个很笨的方法,在ubuntu的字符映射表中去查找(结果是“看来”二字)。 >>>> >>>> 谢谢, >>>> >>>> ph >>>> >>>> -- >>>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 >>>> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 >>>> 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 >>>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 >>>> >>> >>> >>> >>> -- >>> --------------------------- >>> Achilles Xu >>> >>> -- >>> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 >>> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 >>> 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 >>> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 >>> >> >> -- >> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 >> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 >> 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 >> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 >> > > -- > 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 > 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 > 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 > 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 > -- woosley.xu. http://twitter.com/redicaps -- 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
