Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 browsing the Monastery: (7)
As of 2015-07-07 00:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (86 votes), past polls