Skip Menu |

This queue is for tickets about the SVG CPAN distribution.

Report information
The Basics
Id: 121612
Status: resolved
Priority: 0/
Queue: SVG

People
Owner: MANWAR [...] cpan.org
Requestors: perl-svg [...] 1.perl-svg.bgcomp.co.uk
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.76
Fixed in: 2.78



Subject: Bad code produced with degree symbol
Date: Thu, 11 May 2017 12:24:07 +0100
To: bug-SVG [...] rt.cpan.org
From: Bob Goddard <perl-svg [...] 1.perl-svg.bgcomp.co.uk>
Simple code below produces code for the degree symbol as "Temperature & #176". For some reason, I am getting 4 spaces between the ampersand and the hash. The printf statement produces the correct single character. This is with V2.64. #!/usr/bin/perl use base; use POSIX; use SVG; use strict; use warnings; use Carp; use Readonly; Readonly my $DEGREE=>176; Readonly my $rr=>"Temperature " . chr($DEGREE); my $svg = SVG->new(width=>60 + 60 * 60 * 24 * 31 / (60 * 30) + 20, height=>260); $svg->desc()->cdata('Monthly power usage descrption'); $svg->title()->cdata('Monthly power usage'); $svg->rectangle(x=>0, y=>0, width=>(60 + ((60 * 60 * 24 * 31) / (60 * 30)) + 20), rx=>10, ry=>10, height=>260, fill=>'#2080dd', id=>'rect_1'); my $verttxt = $svg->group( id=>"textLayout5", transform=>"translate(0, 0)"); $verttxt->text(x=>"0", y=>"0", style=>{'font-family'=>'Verdana', fill=>'black','font-size'=>"14pt", stroke=>'none', 'writing-mode'=>'lr', 'text-anchor'=>'middle'}, transform=>"translate(30, 130), rotate(-90)" )->cdata($rr); print($rr . '\n'); $verttxt->text(x=>"10", y=>"250", style=>{'font-family'=>'Verdana', fill=>'black','font-size'=>"14pt", stroke=>'none', 'writing-mode'=>'lr', 'text-anchor'=>'start'} )->cdata('Voltage V');
Subject: Re: [rt.cpan.org #121612] AutoReply: Bad code produced with degree symbol
Date: Fri, 12 May 2017 10:23:01 +0100
To: bug-SVG [...] rt.cpan.org
From: Bob Goddard <perl-svg [...] 1.perl-svg.bgcomp.co.uk>
On Thursday, 11 May 2017 07:28:10 BST you wrote: Show quoted text
> > Greetings, > > This message has been automatically generated in response to the > creation of a trouble ticket regarding: > "Bad code produced with degree symbol", > a summary of which appears below. > > There is no need to reply to this message right now. Your ticket has been > assigned an ID of [rt.cpan.org #121612]. Your ticket is accessible > on the web at: > > https://rt.cpan.org/Ticket/Display.html?id=121612 > > Please include the string: > > [rt.cpan.org #121612] > > in the subject line of all future correspondence about this issue. To do so, > you may reply to this message. > > Thank you, > bug-SVG@rt.cpan.org > > ------------------------------------------------------------------------- > Simple code below produces code for the degree symbol as "Temperature & #176". > > For some reason, I am getting 4 spaces between the ampersand and the hash. > > The printf statement produces the correct single character. > > This is with V2.64. > > > > > #!/usr/bin/perl > > use base; > use POSIX; > use SVG; > use strict; > use warnings; > use Carp; > use Readonly; > > Readonly my $DEGREE=>176; > Readonly my $rr=>"Temperature " . chr($DEGREE); > > my $svg = SVG->new(width=>60 + 60 * 60 * 24 * 31 / (60 * 30) + 20, height=>260); > $svg->desc()->cdata('Monthly power usage descrption'); > $svg->title()->cdata('Monthly power usage'); > > $svg->rectangle(x=>0, y=>0, width=>(60 + ((60 * 60 * 24 * 31) / (60 * 30)) + 20), rx=>10, ry=>10, height=>260, fill=>'#2080dd', id=>'rect_1'); > > > my $verttxt = $svg->group( id=>"textLayout5", transform=>"translate(0, 0)"); > $verttxt->text(x=>"0", y=>"0", > style=>{'font-family'=>'Verdana', > fill=>'black','font-size'=>"14pt", > stroke=>'none', > 'writing-mode'=>'lr', > 'text-anchor'=>'middle'}, > transform=>"translate(30, 130), rotate(-90)" > )->cdata($rr); > print($rr . '\n'); > $verttxt->text(x=>"10", y=>"250", > style=>{'font-family'=>'Verdana', > fill=>'black','font-size'=>"14pt", > stroke=>'none', > 'writing-mode'=>'lr', > 'text-anchor'=>'start'} > )->cdata('Voltage V'); >
Sigh... even worse. The line: )->cdata("Temperature °" . chr(176)); produces: Temperature & #194; & #176; & #176 That's, 3 separate attempts at producing the degree symbol, yet only 2 requested, and still 4 spaces between the ampersand and the hash. B
Hi @Bob, Thanks for raising the issue. I have tracked the issue and found the offending lines in the method xmlescp() in the package SVG::XML. According to the git, the line was changed by Gabor as below: ^39c9802 (Gabor Szabo 2012-03-28 22:48:36 +0200 76) # Per suggestion from Adam Schneider 33816b90 (Gabor Szabo 2015-03-06 17:04:54 +0200 77) $s =~ s/([\200-\377])/' & #'.ord($1).';'/ge; I don't know the background why it was changed except that it was suggested by Adam Schneider. I will request Gabor if he remembers anything as it was done long time back. Since I only adopted the distribution recently, I am still familiarizing myself with the code base. However if it is still a blocker for you, you could hack your local copy for the time being. In the mean time, I will try to get to the bottom of the issue. Best Regards, Mohammad S Anwar
Resolved in SVG v2.78