Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: How to handle UTF-8 content with Win32::IE::Mechanize

by 2teez (Priest)
on Dec 03, 2012 at 11:25 UTC ( #1006852=note: print w/ replies, xml ) Need Help??


in reply to How to handle UTF-8 content with Win32::IE::Mechanize

Why not use the open pragma  use open qw(:std :utf8); OR
binmode like so: binmode FILEHANDLE, LAYER. i.e

open DEBUGFILE, '>', "debug.txt" or die $!; binmode DEBUGFILE, ":encoding(UTF-8)";

Using your OP, I don't have Win32::IE::Mechanize, installed so I used WWW::Mechanize, like so:
use WWW::Mechanize; ... # get the DOM document #my $doc = $mech->{agent}->Document; # comment out # get the webpage title my $title = $mech->title; # used instead ... # create a utf-8 text file open DEBUGFILE, '>', "debug.txt" or die $!; binmode DEBUGFILE,":encoding(UTF-8)"; ...
OUTPUT:
Title:야후! 코리아
Title Length:7
Title Hex Byte String:c74c120245ca44
Hope this helps

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me


Comment on Re: How to handle UTF-8 content with Win32::IE::Mechanize
Select or Download Code
Re^2: How to handle UTF-8 content with Win32::IE::Mechanize
by Anonymous Monk on Dec 03, 2012 at 11:44 UTC

      ... And suggesting an alternative would not be wrong either.
      Moreover,Win32::IE::Mechanize is just Like "the mech" but with IE as user-agent. Period...

      If you tell me, I'll forget.
      If you show me, I'll remember.
      if you involve me, I'll understand.
      --- Author unknown to me

        But you didn't actually suggest it as an alternative :)

        Mechanize doesn't support javascript, while iexplore does support javascript -- pretty much the only reason folks use iexplore when they can

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006852]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2014-04-21 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (490 votes), past polls