Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8789911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:31:40+00:00 2026-06-13T22:31:40+00:00

I am retrieving a ´ISO-8859-1´ encoded website by using ´LWP::UserAgent´ with the following code.

  • 0

I am retrieving a ´ISO-8859-1´ encoded website by using ´LWP::UserAgent´ with the following code.

The problem is, that the special characters are not displayed right, especialy the “€” sign is displayed wrong.

The content encoding is recognized as ´ISO-8859-1´, which is right.

To display the retrieved text I am saving it into a file and open it with Notepag++.

Question: How can I retrieve ´ISO-8859-1´ encoded special characters, in the right way?


#SENDING REQUEST
my $ua = LWP::UserAgent->new();
$ua->agent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1'); # pretend we are very capable browser

my $req = HTTP::Request->new(GET => $url);

#add some header fields
$req->header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
$req->header('Accept-Language', 'en;q=0.5');
$req->header('Connection', 'keep-alive');
$req->header('Host', 'www.url.com');

#SEND
my $response = $ua->request($req);

#decode  trial1
print $response->content_charset(); # gives ISO-8859-1 which is right
my $content  = $response->decoded_content(); #special chars are displayed wrong

#decode trial2
my $decContent =  decode('ISO-8859-1', $response->content());
my $utf8Content = encode( 'utf-8', $decContent ); #special char € is displayed as Â

#decode trial3
Encode::from_to($content, 'iso-8859-1', 'utf8'); #special char € is displayed as  too


#example on writing data to file
open(MYOUTFILE, ">>D:\\encodingperl.html"); #open for write, overwrite
print MYOUTFILE "$utf8Content"; #write text
close(MYOUTFILE);


  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:31:40+00:00Added an answer on June 13, 2026 at 10:31 pm

    Same as any other:

    my $content = $response->decoded_content();
    

    That said, the iso-8859-1 charset does not include the Euro sign. You probably actually have cp1252. You can fix that as follows:

    my $content = $response->decoded_content( charset => 'cp1252' );
    

    Your second problem is that you don’t encode your output. This is how you’d do it.

    open(my $MYOUTFILE, '>>:encoding(cp1252)', 'D:\\encodingperl.html')
       or die $!;
    print $MYOUTFILE $content;
    

    Use the encoding that’s appropriate for you (e.g. UTF-8) if it’s not cp1252 you want. If you want the original file in the original encoding, use

    my $content = $response->decoded_content( charset => 'none' );
    

    and

    open(my $MYOUTFILE, '>>', 'D:\\encodingperl.html')
       or die $!;
    binmode($MYOUTFILE);
    print $MYOUTFILE $content;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am retrieving android apps icons using this code : Drawable icon = icon
I'm retrieving an HTML document that is parsed with Nokogiri. The HTML is using
I'm retrieving data from a MySQL table and displaying it on a webpage using
I'm having difficulty retrieving the giftcard code and amount used on an order. For
I'm retrieving a set of location names from a MySQL database using PHP and
I retrieving data from a csv/txt file using oledb driver ConnString = Provider=Microsoft.Jet.OleDb.4.0; Data
I am retrieving a twitter feed using a php file and it is returning
I'm retrieving a batch of items using their keys, with something like this: from
How can we retrieving data from multiple tables without using LEFT JOIN or RIGHT
I'm working on a website which uses / stores accented characters in the database.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.