in reply to UTF8 issue with XML::XPath

here $val is taken from external TXT file.

Did you open that file with <:encoding(UTF-8)? If not, it's a byte string, and probably won't work well with clean modules.

Update: and of course you need the >:encoding(UTF-8) ouput layer when opening the result file.

Replies are listed 'Best First'.
Re^2: UTF8 issue with XML::XPath
by jodaka (Initiate) on Mar 05, 2008 at 11:48 UTC
    no-no, you didn't understand me... the problem is not in text files.
    I can read/write files in UTF8 without any problems (since I'm on linux and UTF8 is my default locale) even without specifying bindmode. my console is in UTF8. And if I run
    print $xp->find('/conf')->get_node(1)->toString();
    it will give me data in wrong encoding. So it's not related with files I/O... it's in XML::XPath
      Even if your default locale is utf8, you need to specify input and output conversions. The locale doesn't effect I/O layer by default (it can be enabled with user open ':locale';, though).

      XML::XPath will most likely return text strings, while print can only work properly with byte strings.

      So you might even want to try binmode STDOUT, ':encoding(UTF-8)'; before printing.

        no, that doesn't help. I told you - it's XML::XPath issue, not my console/IO/locale... hm... looks like I'm going to switch to some other library, like XML::LibXML