.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Quote 3pm" .TH Quote 3pm "2014-04-11" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" XML::Quote \- XML quote/dequote functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use strict; \& use XML::Quote qw(:all); \& \& my $str=q{666 > 444 & "apple" < \*(Aqearth\*(Aq}; \& print xml_quote($str),"\en"; \& # 666 > 444 & "apple" < 'earth' \& \& my $str2=q{666 > 444 & "apple" < 'earth'}; \& print xml_dequote($str2),"\en"; \& # 666 > 444 & "apple" < \*(Aqearth\*(Aq \& \& my $str3=q{666 > 444 & "apple" < \*(Aqearth\*(Aq}; \& print xml_quote_min($str3),"\en"; \& # 666 > 444 & "apple" < \*(Aqearth\*(Aq .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides functions to quote/dequote strings in \*(L"xml\*(R"\-way. .PP All functions are written in \s-1XS\s0 and are very fast; they correctly process utf8, tied, overloaded variables and all the rest of perl \*(L"magic\*(R". .SH "FUNCTIONS" .IX Header "FUNCTIONS" .ie n .IP "$quoted = xml_quote($str);" 4 .el .IP "\f(CW$quoted\fR = xml_quote($str);" 4 .IX Item "$quoted = xml_quote($str);" This function replaces all occurences of symbols '&', '"', ''', '>', '<' to '&', '"', ''', '>', '<' respectively. .Sp Returns quoted string or undef if \f(CW$str\fR is undef. .ie n .IP "$dequoted = xml_dequote($str);" 4 .el .IP "\f(CW$dequoted\fR = xml_dequote($str);" 4 .IX Item "$dequoted = xml_dequote($str);" This function replaces all occurences of '&', '"', ''', '>', \&'<' to '&', '"', ''', '>', '<' respectively. All other entities (for example  ) will not be touched. .Sp Returns dequoted string or undef if \f(CW$str\fR is undef. .ie n .IP "$quoted = xml_quote_min($str);" 4 .el .IP "\f(CW$quoted\fR = xml_quote_min($str);" 4 .IX Item "$quoted = xml_quote_min($str);" This function replaces all occurences of symbols '&', '"', '<' to '&', '"', '<' respectively. Symbols ''' and '>' are not replaced. .Sp Returns quoted string or undef if \f(CW$str\fR is undef. .SH "EXPORT" .IX Header "EXPORT" \&\fIxml_quote()\fR, \fIxml_dequote()\fR are exported as default. .SH "PERFORMANCE" .IX Header "PERFORMANCE" You can use t/benchmark.pl to test the perfomance. Here is the result on my P4 box. .PP .Vb 3 \& Benchmark: timing 1000000 iterations of perl quote, xs quote... \& perl quote: 108 wallclock secs (88.08 usr + 0.01 sys = 88.09 CPU) @ 11351.64/s (n=1000000) \& xs quote: 20 wallclock secs (16.78 usr + 0.00 sys = 16.78 CPU) @ 59591.20/s (n=1000000) \& \& Benchmark: timing 1000000 iterations of perl dequote, xs dequote... \& perl dequote: 106 wallclock secs (85.22 usr + 0.09 sys = 85.31 CPU) @ 11721.54/s (n=1000000) \& xs dequote: 19 wallclock secs (15.92 usr + 0.02 sys = 15.94 CPU) @ 62743.13/s (n=1000000) .Ve .SH "AUTHOR" .IX Header "AUTHOR" Sergey Skvortsov .SH "SEE ALSO" .IX Header "SEE ALSO" , perlre .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 2003 Sergey Skvortsov . All rights reserved. .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.