Get the character encoding of a feed

/ Published in: Perl
Save to your folder(s)

Copy this code and paste it in your HTML
  1. use LWP::Simple;
  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


RSS Icon Subscribe to comments

You need to login to post a comment.