XML::Li...::Common(3)
π NAME π
XML::LibXML::Common β it's giving constants + character encoding routines β¨ the whole vibe.
πΈ SYNOPSIS πΈ
use XML::LibXML::Common;
$encodedstring = encodeToUTF8( $name_of_encoding, $sting_to_encode );
$decodedstring = decodeFromUTF8($name_of_encoding, $string_to_decode );
yes bestie, $sting_to_encode is literally how it's written in the original. typos are canon, we don't touch them π
π¦ DESCRIPTION π¦
Okay so XML::LibXML::Common does two things and it does them well, no cap: it defines constants for all node types, and it gives you an interface to the libxml2 charset conversion functions. iconic behaviour honestly.
And because XML::LibXML uses its own node type definitions, you might wanna run XML::LibXML::Common in its compatibility mode. that's the tea.
β¨ Exporter TAGS β¨
use XML::LibXML::Common qw(:libxml);
the :libxml tag drops you into XML::LibXML Compatibility mode, which defines the old XML_ node-type definitions. retro but make it fashion π
use XML::LibXML::Common qw(:gdome);
the :gdome tag hits up XML::GDOME Compatibility mode, which defines the old GDOME_ node-type definitions.
use XML::LibXML::Common qw(:w3c);
this one uses the nodetype definition names as specified for DOM. as the universe intended, lowkey.
use XML::LibXML::Common qw(:encoding);
use this tag when you literally only want the charset encoding functions from XML::LibXML::Common and nothing else. minimalist queen π§
π Exports π
By default, the W3 definitions as defined in the DOM specifications and the encoding functions are exported by XML::LibXML::Common. so you get both, no need to ask twice π«Ά
π Encoding functions π
So, to encode or decode a string to or from UTF-8, XML::LibXML::Common exports two functions, which provide an interface to the encoding support in libxml2.
Which encodings are supported by these functions depends on how libxml2 was compiled. π
UTF-16 is always supported, and on most installations, ISO encodings are supported as well. periodt.
ngl this interface was useful for older versions of Perl. Since Perl >= 5.8 provides similar functions via the Encode module, it is probably a good idea to use those instead. just saying π
β encodeToUTF8 β
$encodedstring = encodeToUTF8( $name_of_encoding, $sting_to_encode );
This function will convert a byte string from the specified encoding to an UTF-8 encoded character string. glow up for your bytes β¨
π decodeToUTF8 π
$decodedstring = decodeFromUTF8($name_of_encoding, $string_to_decode );
This function converts an UTF-8 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. it's giving unsalvageable π
Both these functions report their errors on the standard error. If an error occurs the function will croak(). 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. protect your script's peace, bestie π
π A note on history π
Before XML::LibXML 1.70, this class was available as a separate CPAN distribution, intended to provide functionality shared between XML::LibXML, XML::GDOME, and possibly other modules. Since there seems to be no progress in this direction, they decided to merge XML::LibXML::Common 0.13 and XML::LibXML 1.70 into one CPAN distribution. a merger arc, main character energy π
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. yeah. that was a jumpscare π
π AUTHORS π
Matt Sergeant, Christian Glahn, Petr Pajas β the founding mothers of this whole situation, fr fr π«Ά
β VERSION β
2.0213
π COPYRIGHT π
- 2001-2007, AxKit.com Ltd.
- 2002-2006, Christian Glahn.
- 2006-2009, Petr Pajas.
π LICENSE π
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay, no further questions β¨
okay that's the whole page babes π this was perl v5.42.2, dated 2026-05-25, and you just read the manual page for XML::Li...::Common(3) β the User Contributed Perl Documentation one. go forth and encode responsibly πΈπ¦
π¦ where this page comes from
- fedora 43: perl-XML-LibXML 1:2.0213-1.fc43 Β· (GPL-1.0-or-later OR Artistic-1.0-Perl) AND MIT
- fedora 44: perl-XML-LibXML 1:2.0213-1.fc44 Β· (GPL-1.0-or-later OR Artistic-1.0-Perl) AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms