Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^4: convert encoding

by rumpumpel1 (Novice)
on Feb 23, 2017 at 09:54 UTC ( [id://1182615]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1182615]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-25 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found