在PERL中从cp1252转换为latin1时会删除换行符

时间:2014-08-21 13:54:23

标签: perl

my $csv_parser = Text::CSV_XS->new();

print STDERR "before calling subroutine :\n";
print STDERR $content."<br>";

以上印刷品:

before calling subroutine :

variation ID,Product title,Description,Keywords,Subcat

,Arc Lightning,,among andor arc battl box choo choos common creatur damag deal divid adsf af

,Ashnod's Coupon,,artifact ashnod coupon drink english gather get magic mint mintnear asdf
af

,Bonesplitter,,artifact attach bonesplitt card come common control creatur english equip 

现在检查一下这段代码:

$content = common::make_text_latin1(
  'string' => $content,
);

make_text_latin1检查字符编码格式并转换为latin1

if($guess->name eq 'cp1252') {
  #converting to latin1
  $string = $param{'string'};
  Encode::from_to($string,"cp1252", "latin1");
}

print STDERR "After calling subroutine: \n";

打印

After calling subroutine:
variation ID,Product title,Description,Keywords,Subcat, Arc Lightning,,among andor arc battl box choo choos common creatur damag deal divid adsf af ,Ashnod's Coupon,,artifact ashnod coupon drink english gather get magic mint mintnear asdf
af ,Bonesplitter,,artifact attach bonesplitt card come common control creatur english equip 

转换后会删除换行符。为什么这样做?如果有人能帮助我解决上述问题会很有帮助。

0 个答案:

没有答案