Posted By

eszpee on 01/18/08


Tagged

feed utf8 encoding i18n LWPSimple


Versions (?)

Get the character encoding of a feed


 / Published in: Perl
 

  1. use LWP::Simple;
  2.  
  3. sub getfeedencoding {
  4. #takes: feed url
  5. #returns: feed encoding based on what it says about itself in the XML header
  6. #sample string: encoding="UTF-8"
  7. my $feedurl = shift;
  8. my $pagecontent = get($feedurl);
  9. $pagecontent =~ m{encoding="(.*?)"};
  10. return $1 or undef;
  11. }

Report this snippet  

You need to login to post a comment.