Please make txt2svg.pl cope with UTF-8 (patch included)

Bug #1026173 reported by Reuben Thomas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Medium
Reuben Thomas

Bug Description

txt2svg.pl, used to import text files, can only cope with 7-bit ASCII: implicitly, its output is UTF-8 encoded, but it actually reads its input as 8-bit text, and re-encodes it on output (again, implicitly). Since the default encoding of the output SVG is UTF-8, anything other than 7-bit ASCII is mangled.

The following patch improves this by supporting UTF-8. Other 8-bit input is, as before, silently mangled. It uses the Encode module, which has been a part of standard Perl for many years. I've tested this script with Inkscape 0.48.3, and confirmed that the version of txt2svg.pl supplied there is the same as in current Bazaar.

--- /usr/share/inkscape/extensions/txt2svg.pl 2012-03-29 19:46:17.000000000 +0100
+++ /home/rrt/bin/txt2svg.pl 2012-07-18 15:36:00.625196753 +0100
@@ -4,8 +4,11 @@

 use strict;
 use SVG;
+use Encode;
 use vars qw($VERSION);
-$VERSION = '1.00';
+$VERSION = '1.01';
+
+binmode(STDOUT, ":utf8");

 my $svg = new SVG;

@@ -25,7 +28,7 @@
          'font-size' => 10,
      }
      )
- ->cdata($_);
+ ->cdata(decode_utf8($_));
     $i++;
 }

su_v (suv-lp)
tags: added: extensions-plugins
Revision history for this message
su_v (suv-lp) wrote :

Reproduced with Inkscape 0.48.3.1 and Inkscape 0.48+devel r11552 on OS X 10.7.4

Changed in inkscape:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
su_v (suv-lp) wrote :

Patch tested successfully with perl 5.12.4

$ perl --version

This is perl 5, version 12, subversion 4 (v5.12.4) built for darwin-thread-multi-2level

Revision history for this message
jazzynico (jazzynico) wrote :

Bug and fix confirmed on Ubuntu 11.04.

Committed in the trunk (revision 11553) and branch (revision 9902).
Thanks for the patch!

Changed in inkscape:
assignee: nobody → Reuben Thomas (rrt)
milestone: none → 0.48.4
status: Confirmed → Fix Committed
Ted Gould (ted)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.