Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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

Replies are listed 'Best First'.
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?
[marto]: One of the main train stations is right across the road, so handy from that perspective, and there are some nice hotels in the area, but it's not great after dark, or sometimes during the day to be honest
[LanX]: not easy to find good and affordable venues ...
[marto]: hmm, there are several universities and colleges handy that I'd have thought would offer such services, given this is out of term time, I've no experience of paying for venues :)
[LanX]: OK ...
[LanX]: I have no idea how Mark scouted, giving that he lives in London ... but I think he mentioned his wife being Scottish
[marto]: ah, so this is payback :P
[LanX]: problem with booking venues is that you only know the number of participants a week in advance. ..
[marto]: I guess most cities have areas similar to this, I tend not to mind personally, but would not go out of my way to head down that way
[marto]: it'll probably be fine.
[marto]: LanX: I appreciate that, it's honestly a difficult thing, a fine balance

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2017-12-14 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (396 votes). Check out past polls.

    Notices?