[librdf-rdfa-generator-perl] 14/64: utf8-encoding

Jonas Smedegaard dr at jones.dk
Sat Dec 23 12:22:51 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.106-1
in repository librdf-rdfa-generator-perl.

commit 8bdeca30f682e3a895fab2e8ac937c37f1c4baee
Author: Toby Inkster <mail at tobyinkster.co.uk>
Date:   Thu May 27 20:56:40 2010 +0000

    utf8-encoding
    
    --HG--
    branch : RDF-RDFa-Generator
    extra : convert_revision : svn%3A3fe8e991-6959-4966-b76d-b07eca2b6e37/RDF-RDFa-Generator%40373
---
 example1-out.html                     |  4 +---
 example1.pl                           |  1 +
 lib/RDF/RDFa/Generator/HTML/Head.pm   |  3 ++-
 lib/RDF/RDFa/Generator/HTML/Pretty.pm | 11 ++++++-----
 4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/example1-out.html b/example1-out.html
index c7fdb3d..9aeb169 100644
--- a/example1-out.html
+++ b/example1-out.html
@@ -3,11 +3,9 @@
 <head profile="http://www.w3.org/1999/xhtml/vocab">
 <title>RDFa Document</title>
 <meta nane="generator" value="RDF::RDFa::Generator::HTML::Pretty"/>
-<link rel="stylesheet" type="text/css" href="example1.css"/>
 </head>
 <body>
 <h1>RDFa Document</h1>
 <p><small>Generated by RDF::RDFa::Generator::HTML::Pretty.</small></p>
-<div xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:xhv="http://www.w3.org/1999/xhtml/vocab#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><div about="[_:r724178C05AEB11DFB1F4D1FFE6B6D6BAr0]"><h3 class="blank">_:r724178C05AEB11DFB1F4D1FFE6B6D6BAr0</h3><span class="rdf-type" rel="rdf:type"><img about="http://xmlns.com/foaf/0.1/Person" alt="http://xmlns.com/foaf/0.1/Person" src="data:image/png;charset=binary;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhki [...]
+<div xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:xhv="http://www.w3.org/1999/xhtml/vocab#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><div about="http://example.net/"><h3 class="resource">http://example.net/</h3><span class="rdf-type" rel="rdf:type"><img about="http://xmlns.com/foaf/0.1/Document" alt="http://xmlns.com/foaf/0.1/Document" src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXH [...]
 </html>
-[?1049h(B[?7h[?12l[?25h[?1h=[?1h=[?1h=(B(B  GNU nano 2.0.9             File: example1.pl                                  (Buse lib "lib";
use RDF::TrineShortcuts;
use RDF::RDFa::Generator;
my $graph = rdf_parse(<<TURTLE, type=>'turtle');
\@prefix foaf: <http://xmlns.com/foaf/0.1/> .
\@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<http://example.net/>a foaf:Document ;<http://www.w3.org/1999/xhtml/vocab#next> <http://example.net/page2> ;<http://www.w3.org/1999/xhtml/vocab#title> "About Joe"@en ;foaf:primaryTopic [a foaf:Person ;foaf:name "Joe Bloggs" ;foaf:plan "To conquer the world!"\@en(B[ Read 26 lines ]
^G(B Get Help  (B^O(B WriteOut  (B^R(B Read File (B^Y(B Prev Page (B^K(B Cut Text  (B^C(B Cur Pos
(B^X(B Exit(B^J(B Justify   (B^W(B Where Is  (B^V(B Next Page (B^U(B UnCut Text(B^T(B To Spell
(B[ line 1/27 (3%), col 1/15 (6%), char 0/705 (0%) ]
(B[?1049l
[?1l>
\ No newline at end of file
diff --git a/example1.pl b/example1.pl
index 7a30c6e..0038b3d 100644
--- a/example1.pl
+++ b/example1.pl
@@ -18,6 +18,7 @@ my $graph = rdf_parse(<<TURTLE, type=>'turtle');
 		foaf:name "Joe Bloggs" ;
 		foaf:plan "To conquer the world!"\@en
 	] ;
+	foaf:utf8 "fæces" ;
 	foaf:segment "Hello <b xmlns='http://www.w3.org/1999/xhtml'>World</b>"^^rdf:XMLLiteral .
 
 TURTLE
diff --git a/lib/RDF/RDFa/Generator/HTML/Head.pm b/lib/RDF/RDFa/Generator/HTML/Head.pm
index d7cd57d..072cdc5 100644
--- a/lib/RDF/RDFa/Generator/HTML/Head.pm
+++ b/lib/RDF/RDFa/Generator/HTML/Head.pm
@@ -3,6 +3,7 @@ package RDF::RDFa::Generator::HTML::Head;
 use 5.008;
 use base qw'RDF::RDFa::Generator';
 use common::sense;
+use Encode qw'encode_utf8';
 use XML::LibXML qw':all';
 
 our $VERSION = '0.04';
@@ -219,7 +220,7 @@ sub _process_object
 		return $self;
 	}
 	
-	$node->setAttribute('content',  $st->object->literal_value);
+	$node->setAttribute('content',  encode_utf8($st->object->literal_value));
 	
 	if (defined $st->object->literal_datatype)
 	{
diff --git a/lib/RDF/RDFa/Generator/HTML/Pretty.pm b/lib/RDF/RDFa/Generator/HTML/Pretty.pm
index bb7aa63..90d9687 100644
--- a/lib/RDF/RDFa/Generator/HTML/Pretty.pm
+++ b/lib/RDF/RDFa/Generator/HTML/Pretty.pm
@@ -4,6 +4,7 @@ use 5.008;
 use base qw'RDF::RDFa::Generator::HTML::Hidden';
 use common::sense;
 use constant XHTML_NS => 'http://www.w3.org/1999/xhtml';
+use Encode qw'encode_utf8';
 use Icon::FamFamFam::Silk;
 use RDF::RDFa::Generator::HTML::Pretty::Note;
 use XML::LibXML qw':all';
@@ -199,7 +200,7 @@ sub _resource_statements
 			$DD->setAttribute('property',  $self->_make_curie($st->predicate->uri, $prefixes));
 			$DD->setAttribute('class', 'plain-literal');
 			$DD->setAttribute('xml:lang',  $st->object->literal_value_language);
-			$DD->appendTextNode($st->object->literal_value);
+			$DD->appendTextNode(encode_utf8($st->object->literal_value));
 		}
 		elsif ($self->{'safe_xml_literals'}
 		&& $st->object->is_literal
@@ -209,8 +210,8 @@ sub _resource_statements
 			$DD->setAttribute('property',  $self->_make_curie($st->predicate->uri, $prefixes));
 			$DD->setAttribute('class', 'typed-literal datatype-xmlliteral');
 			$DD->setAttribute('datatype',  $self->_make_curie($st->object->literal_datatype, $prefixes));
-			$DD->setAttribute('content', $st->object->literal_value);
-			$DD->addNewChild(XHTML_NS, 'pre')->addNewChild(XHTML_NS, 'code')->appendTextNode($st->object->literal_value);
+			$DD->setAttribute('content', encode_utf8($st->object->literal_value));
+			$DD->addNewChild(XHTML_NS, 'pre')->addNewChild(XHTML_NS, 'code')->appendTextNode(encode_utf8($st->object->literal_value));
 		}
 		elsif ($st->object->is_literal
 		&& $st->object->has_datatype
@@ -219,7 +220,7 @@ sub _resource_statements
 			$DD->setAttribute('property',  $self->_make_curie($st->predicate->uri, $prefixes));
 			$DD->setAttribute('class', 'typed-literal datatype-xmlliteral');
 			$DD->setAttribute('datatype',  $self->_make_curie($st->object->literal_datatype, $prefixes));
-			$DD->appendWellBalancedChunk($st->object->literal_value);
+			$DD->appendWellBalancedChunk(encode_utf8($st->object->literal_value));
 		}
 		elsif ($st->object->is_literal
 		&& $st->object->has_datatype)
@@ -227,7 +228,7 @@ sub _resource_statements
 			$DD->setAttribute('property',  $self->_make_curie($st->predicate->uri, $prefixes));
 			$DD->setAttribute('class', 'typed-literal');
 			$DD->setAttribute('datatype',  $self->_make_curie($st->object->literal_datatype, $prefixes));
-			$DD->appendTextNode($st->object->literal_value);
+			$DD->appendTextNode(encode_utf8($st->object->literal_value));
 		}
 	}
 	

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/librdf-rdfa-generator-perl.git



More information about the Pkg-perl-cvs-commits mailing list