homepage Welcome to WebmasterWorld Guest from 54.167.41.199
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
LWP::UserAgent malformed text
parrot




msg:4229538
 12:09 pm on Nov 12, 2010 (gmt 0)

Hey guys, I am using LWP::UserAgent to import data from a website into a database but I get malformed text. When I look in the source of the original I see chars like ok but when imported I get weird chars like below. Any ideas?

Wir knnen -> Wir können
TV absolvieren -> TÜV absolvieren

Cheers,

Ton

 

chorny




msg:4229597
 3:52 pm on Nov 12, 2010 (gmt 0)

You receive data in utf8 format. See [perldoc.perl.org...] [search.cpan.org...]

If you don;t activate utf8 support in DB connection, Db will not know that you receive utf8.

Possible solution is to use Encode module [search.cpan.org].

parrot




msg:4229607
 4:17 pm on Nov 12, 2010 (gmt 0)

Hey Chorny, thank you for your reply. I just found the solution.

I changed:

$Source2 = $res->content;

into:

$Source2 = $res->decoded_content;

Works great now;-)

Cherio!

janharders




msg:4229635
 5:25 pm on Nov 12, 2010 (gmt 0)

Yupp, that's what I was going to suggest when I read your first post.
I ran into that a few times. Does anyone know if ->decoded_content has any major drawbacks? Most people use ->content, even in documentation, and don't worry about character encoding.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved