When I trying to download some HTML file with the code below:
$mech->get($link)
$mech->save_content("file.html");
I get the warning:
Wide character in print at C:/strawberry/perl/site/lib/WWW/Mechanize.pm line 2040.
Could someone explain how I can repair this warning?
You’ll need to ensure that the output filehandles are opened with the proper encoding.
From a brief glance at the docs, it doesn’t look like Mech has configurable encodings for saved files, so you can grab the content and save it yourself:
The
:utf8bit in theopenwill make sure that data sent to the filehandle is encoded properly as UTF-8.Another way to do it is to encode manually: