Blob Blame History Raw
From c88436e0e97fb4efba5432add1af480bcaa099b1 Mon Sep 17 00:00:00 2001
From: "H.Merijn Brand - Tux" <h.m.brand@xs4all.nl>
Date: Tue, 11 Jun 2013 14:48:52 +0200
Subject: [PATCH] Text::CSV_XS is allowed to return encoded data if valid UTF-8

Text::CSV_XS 0.99 fixed automatic encoding of valid UTF-8
---
 sandbox/genMETA.pl | 2 +-
 t/48_utf8.t        | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

#diff --git a/sandbox/genMETA.pl b/sandbox/genMETA.pl
#index 3ea13e1..4ddde8a 100755
#--- a/sandbox/genMETA.pl
#+++ b/sandbox/genMETA.pl
#@@ -67,7 +67,7 @@
#     charnames:           0
# recommends:
#     perl:                5.016003
#-    Test::More:          0.98
#+    Test::More:          0.99
# installdirs:             site
# resources:
#     license:             http://dev.perl.org/licenses/
diff --git a/t/48_utf8.t b/t/48_utf8.t
index 04a5d91..0230b4f 100644
--- a/t/48_utf8.t
+++ b/t/48_utf8.t
@@ -43,7 +43,9 @@ foreach my $tbl ($tbl1, $tbl2) {
     ok ($sth->execute,				"execute");
     foreach my $i (1 .. scalar @data) {
 	ok ($row = $sth->fetch,			"fetch $i");
-	is_deeply ($row, [ $i , encode ("utf8", $data[$i - 1]) ],	"unencoded content $i");
+	my $v = $data[$i - 1];
+	utf8::is_utf8 ($v) or $v = encode ("utf8", $v);
+	is_deeply ($row, [ $i , $v ],		"unencoded content $i");
 	}
     ok ($sth->finish,				"finish");
     undef $sth;
@@ -57,7 +59,9 @@ foreach my $tbl ($tbl1, $tbl2) {
     ok ($sth->execute,				"execute");
     foreach my $i (1 .. scalar @data) {
 	ok ($row = $sth->fetch,			"fetch $i");
-	is_deeply ($row, [ $i , $data[$i - 1] ],	"encoded content $i");
+	my $v = $data[$i - 1];
+	ok (utf8::is_utf8 ($v),			"is encoded");
+	is_deeply ($row, [ $i , $v ],		"encoded content $i");
 	}
     ok ($sth->finish,				"finish");
     undef $sth;
-- 
1.8.5.1