Hi monks, i've got a weird issue with russian letters in XML::XPath.
The background is:
an XML configuration file with descriptions in different languages. File encoding is UTF8.
Now I want to import some descriptions from other language files (which are all in UTF8 as well).
$xp = XML::XPath->new(filename => 'config.xml');
$xp->setNodeText(qq~/conf/section[\@name="$name"]/description[\@lang="
+$lang"]~, $val);
here $val is taken from external TXT file. Running
$xp->find(qq~/conf/section[\@name="$name"]/description[\@lang="$lang"]
+~)->get_node(1)->string_value();
will produce me 'это тестовая строка' - a nice UTF8 string in Russian.
That's fine.
now, at the end I want to save my changed XML file and I'm doing something like this:
open(XML, ">config.xml");
print XML $xp->find('/conf')->get_node(1)->toString;
close XML;
The problem here is in toString method. It kill my lovely UTF8 russian text...
it transforms 'это тестовая строка' into сновне насойки
:(
looks like toString output is iso8859-1, not UTF8. There's no info in XML::XPath manual about charsets and I'm stuck with it
any advices? How do I tell XML::XPath to give me UTF8 results, not iso8859-1 ?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.