.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" 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 "XML::LibXML::Common 3pm" .TH XML::LibXML::Common 3pm "2017-10-29" "perl v5.26.0" "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::LibXML::Common \- Constants and Character Encoding Routines .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use XML::LibXML::Common; \& \& $encodedstring = encodeToUTF8( $name_of_encoding, $sting_to_encode ); \& $decodedstring = decodeFromUTF8($name_of_encoding, $string_to_decode ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" XML::LibXML::Common defines constants for all node types and provides interface to libxml2 charset conversion functions. .PP Since XML::LibXML use their own node type definitions, one may want to use XML::LibXML::Common in its compatibility mode: .SS "Exporter \s-1TAGS\s0" .IX Subsection "Exporter TAGS" .Vb 1 \& use XML::LibXML::Common qw(:libxml); .Ve .PP \&\f(CW\*(C`:libxml\*(C'\fR tag will use the XML::LibXML Compatibility mode, which defines the old '\s-1XML_\s0' node-type definitions. .PP .Vb 1 \& use XML::LibXML::Common qw(:gdome); .Ve .PP \&\f(CW\*(C`:gdome\*(C'\fR tag will use the \s-1XML::GDOME\s0 Compatibility mode, which defines the old '\s-1GDOME_\s0' node-type definitions. .PP .Vb 1 \& use XML::LibXML::Common qw(:w3c); .Ve .PP This uses the nodetype definition names as specified for \s-1DOM.\s0 .PP .Vb 1 \& use XML::LibXML::Common qw(:encoding); .Ve .PP This tag can be used to export only the charset encoding functions of XML::LibXML::Common. .SS "Exports" .IX Subsection "Exports" By default the W3 definitions as defined in the \s-1DOM\s0 specifications and the encoding functions are exported by XML::LibXML::Common. .SS "Encoding functions" .IX Subsection "Encoding functions" To encode or decode a string to or from \s-1UTF\-8,\s0 XML::LibXML::Common exports two functions, which provide an interface to the encoding support in \f(CW\*(C`libxml2\*(C'\fR. Which encodings are supported by these functions depends on how \f(CW\*(C`libxml2\*(C'\fR was compiled. \s-1UTF\-16\s0 is always supported and on most installations, \s-1ISO\s0 encodings are supported as well. .PP This interface was useful for older versions of Perl. Since Perl >= 5.8 provides similar functions via the \f(CW\*(C`Encode\*(C'\fR module, it is probably a good idea to use those instead. .IP "encodeToUTF8" 4 .IX Item "encodeToUTF8" .Vb 1 \& $encodedstring = encodeToUTF8( $name_of_encoding, $sting_to_encode ); .Ve .Sp The function will convert a byte string from the specified encoding to an \s-1UTF\-8\s0 encoded character string. .IP "decodeToUTF8" 4 .IX Item "decodeToUTF8" .Vb 1 \& $decodedstring = decodeFromUTF8($name_of_encoding, $string_to_decode ); .Ve .Sp This function converts an \s-1UTF\-8\s0 encoded character string to a specified encoding. Note that the conversion can raise an error if the given string contains characters that cannot be represented in the target encoding. .PP Both these functions report their errors on the standard error. If an error occurs the function will \fIcroak()\fR. To catch the error information it is required to call the encoding function from within an eval block in order to prevent the entire script from being stopped on encoding error. .SS "A note on history" .IX Subsection "A note on history" Before XML::LibXML 1.70, this class was available as a separate \s-1CPAN\s0 distribution, intended to provide functionality shared between XML::LibXML, \&\s-1XML::GDOME,\s0 and possibly other modules. Since there seems to be no progress in this direction, we decided to merge XML::LibXML::Common 0.13 and XML::LibXML 1.70 to one \s-1CPAN\s0 distribution. .PP The merge also naturally eliminates a practical and urgent problem experienced by many XML::LibXML users on certain platforms, namely mysterious misbehavior of XML::LibXML occurring if the installed (often pre-packaged) version of XML::LibXML::Common was compiled against an older version of libxml2 than XML::LibXML. .SH "AUTHORS" .IX Header "AUTHORS" Matt Sergeant, Christian Glahn, Petr Pajas .SH "VERSION" .IX Header "VERSION" 2.0128 .SH "COPYRIGHT" .IX Header "COPYRIGHT" 2001\-2007, AxKit.com Ltd. .PP 2002\-2006, Christian Glahn. .PP 2006\-2009, Petr Pajas. .SH "LICENSE" .IX Header "LICENSE" This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.