in reply to Re^3: convert encoding
in thread convert encoding

use strict; use Lyo::OSLC::CQ::CM; use Data::Dumper; use Encode qw(encode decode); ... my $client = Lyo::OSLC::CQ::CM->new; ... my $data = $client->oslcWhere(...); # get data from ClearQuest my $xml = Dumper($data); my $xml_out = encode('UTF-8', $xml); print $xml_out;

Replies are listed 'Best First'.
Re^5: convert encoding
by haukex (Archbishop) on Feb 23, 2017 at 10:05 UTC

    I am wondering why you are using Dumper() and encode() at all? What happens when you do the following?

    use open qw/:std :utf8/; use strict; use Lyo::OSLC::CQ::CM; ... my $client = Lyo::OSLC::CQ::CM->new; ... my $data = $client->oslcWhere(...); print $data;

    The documentation of the ->oslcWhere() method of the module Lyo::OSLC::CQ::CM (which does not appear to be on CPAN; so I hope I've found the right one via googling) says:

    The response from the server is returned in XML format.

    So in that case I would use an XML parser such as XML::LibXML to parse it.

Re^5: convert encoding
by Corion (Patriarch) on Feb 23, 2017 at 09:59 UTC

    Why do you have a string named $xml which is assigned the output of Data::Dumper?

    Note that, as I already said, Data::Dumper likely doesn't output characters above 127 but instead outputs Perl code that's roughly equivalent.

    You most likely want to construct your strings differently.

    What is the actual content of $data?

    Maybe you want to re-read SSCCE (which I misspelled earlier, sorry) to give us some more concrete code, data and output to work with.