Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: convert encoding

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


in reply to Re: convert encoding
in thread convert encoding

using your example code the output still shows "Nach R\x{fc}cksprache mit".

For output I would like to have utf8. Unfortunately I don't know what the input encoding is.

Replies are listed 'Best First'.
Re^3: convert encoding
by Corion (Patriarch) on Feb 23, 2017 at 09:42 UTC

    The output of Data::Dumper will always show Nach R\x{fc}cksprache mit because Data::Dumper tries to restrict its output to 7-bit ASCII, at least with some options.

    If you want something else, please show a SSCCESCCEE, because I don't really understand what you're asking for and it's most easy to demonstrate in ten lines of code.

      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;

        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.

        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://1182610]
help
Chatterbox?
and the web crawler heard nothing...

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

      No recent polls found