]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
Add a patch deal with UTF-8 csv table's problem
authortumashu1 <tumashu1@web>
Sun, 2 Dec 2018 00:55:16 +0000 (20:55 -0400)
committeradmin <admin@branchable.com>
Sun, 2 Dec 2018 00:55:16 +0000 (20:55 -0400)
doc/bugs/table_can_not_deal_with_Chinese_.mdwn

index fe71686e6f52ef355b683e62680bfcd818459620..d9ca6ec1ff9c3921c7e25b91028937a31a0a2b98 100644 (file)
@@ -34,3 +34,53 @@ The below example works well too
 >> A related problem, also fixed by using DSV, is messing up the encoding of non-ASCII, non-wide characters, e.g. £ (workaround was to use &amp;pound; instead) -- [[Jon]]
 
 >>> Sorry, I have faced the same error: \[[!table Error: Cannot decode string with wide characters at /usr/lib/x86_64-linux-gnu/perl/5.24/Encode.pm line 243.]] -- [[tumashu1]]
+
+---
+
+The below patch seem to deal with this problem:
+
+    From d6ed90331b31e4669222c6831f7a0f40f0677fe1 Mon Sep 17 00:00:00 2001
+    From: Feng Shu <tumashu@163.com>
+    Date: Sun, 2 Dec 2018 08:41:39 +0800
+    Subject: [PATCH 2/2] Fix table plugin can handle UTF-8 csv format
+    
+    ---
+     IkiWiki/Plugin/table.pm | 3 ++-
+     1 file changed, 2 insertions(+), 1 deletion(-)
+    
+    From ad1a92c796d907ad293e572a168b6e9a8219623f Mon Sep 17 00:00:00 2001
+    From: Feng Shu <tumashu@163.com>
+    Date: Sun, 2 Dec 2018 08:41:39 +0800
+    Subject: [PATCH 2/2] Fix table plugin can handle UTF-8 csv format
+    
+    ---
+     IkiWiki/Plugin/table.pm | 3 ++-
+     1 file changed, 2 insertions(+), 1 deletion(-)
+    
+    diff --git a/IkiWiki/Plugin/table.pm b/IkiWiki/Plugin/table.pm
+    index f3c425a37..7fea8ab1c 100644
+    --- a/IkiWiki/Plugin/table.pm
+    +++ b/IkiWiki/Plugin/table.pm
+    @@ -135,6 +135,7 @@ sub split_csv ($$) {
+       my $csv = Text::CSV->new({ 
+               sep_char        => $delimiter,
+               binary          => 1,
+    +          decode_utf8 => 1,
+               allow_loose_quotes => 1,
+       }) || error("could not create a Text::CSV object");
+       
+    @@ -143,7 +144,7 @@ sub split_csv ($$) {
+       foreach my $line (@text_lines) {
+               $l++;
+               if ($csv->parse($line)) {
+    -                  push(@data, [ map { decode_utf8 $_ } $csv->fields() ]);
+    +                  push(@data, [ $csv->fields() ]);
+               }
+               else {
+                       debug(sprintf(gettext('parse fail at line %d: %s'), 
+    -- 
+    2.19.0
+    
+
+    
+