2009年1月4日星期日

[PerlChina] Re: perl读取access数据库时由于值里包含windows路径的"\"导致的问题

先查看下数据库链接编码是啥,脚本编码和他保持一直,然后再试试decode下列值
--
blog : http://hi.baidu.com/smallfish7788
bbs : http://bbs.chinaunix.net/forum-55-1.html
smallfish / xiaoyu9805119

--------------------------------------------------
From: "大大" <xiaozuovip@gmail.com>
Sent: Monday, January 05, 2009 10:08 AM
To: "PerlChina 论坛" <perlchina@googlegroups.com>
Subject: [PerlChina] Re: perl读取access数据库时由于值里包含windows路径的"\"导致的问题

> 我知道了,是由于数据库中值是汉字的缘故,我换成数字和字母后,即使加上 \ /
> ( ) 之类也没问题了,请教各位大大,如何才能正确读取到汉字呢,
> 我先google一下去。
>
> On 1月4日, 下午9时17分, "Qiang (James)" <shijia...@gmail.com> wrote:
>> > while ( $ary_ref = $sth->fetchrow_arrayref) {
>>
>> > print FILE1 ("$ary_ref->[0] : $ary_ref->[1] : $ary_ref->[2] \n";
>> > print FILE1 ("$ary_ref->[0] \n";
>> > }
>>
>> > 当运行的时候报告错误:
>>
>> > DBD::ODBC::st fetchrow_arrayref failed: [Microsoft][ODBC Microsoft
>> > Access Driver
>> > ]字符串数据,右截断 在列号 3 (CopyDetail) (SQL-01004) at D:\jk\test1.pl
>> > line 31.
>>
>> > [Microsoft][ODBC Microsoft Access Driver]字符串数据,右截断 在列号 3
>> > (CopyDetail
>> > ) (SQL-01004) at D:\jk\test1.pl line 39.
>>
>> > 我检查后发现,是由于第三列内容包含windows路径的"\"导致的,当运行到
>> > while ( $ary_ref = $sth-
>> >> fetchrow_arrayref )的时候,就开始报告错误
>>
>> > 请问各位,我该怎么做才能使perl正确读取"\"字符呢。
>>
>> 在你决定是 \ 的问题前,建议再仔细的 debug 一下。例如通过 use Data::
>> Dumer, 在每次循环时都 print Dumper $ary_ref;看看你的程序是否运行到这一
>> 步,得到的结果是否正常。
>>
>> 另外也建议读一下这篇 debug 文章http://wiki.perlchina.org/index.php/Brian%27s_Guide_to_Solving_Any_Pe...
>>
>> Qiang(James)- 隐藏被引用文字 -
>>
>> - 显示引用的文字 -
> >
>

--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛"PerlChina 论坛"论坛。
要在此论坛发帖,请发电子邮件到 perlchina@googlegroups.com
要退订此论坛,请发邮件至 perlchina+unsubscribe@googlegroups.com
更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---

没有评论: