Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: HTML::Entities not working

by muba (Priest)
on Jun 19, 2013 at 08:31 UTC ( #1039743=note: print w/replies, xml ) Need Help??


in reply to HTML::Entities not working

I can't reproduce your problem.

length.htm:

<html> <body> <form method="POST" action="length.cgi"> <input type="text" name="message" /> <input type="submit" /> </form> </body> </html>

length.cgi:

#!perl use strict; use warnings use HTML::Entities; use CGI; my $cgi=new CGI; my $message=$cgi->param('message'); $message=decode_entities($message); my $message_fld_length=length($message); # Obviously, if I call this script as a CGI script, it won't work unle +ss I send the # minimal set of HTTP headers! print "Content-Type: text/html\n\n"; print "$message_fld_length";

Input: output (expected output)
Other language: 14 (14)
&nbsp;: 1 (1)

What does your HTML look like? What is your input? What output do you expect? What output do you get?

Replies are listed 'Best First'.
Re^2: HTML::Entities not working
by vasanthgk91 (Sexton) on Jun 19, 2013 at 09:14 UTC

    This is my input: 社論並指,香港及中國輿論反對引渡史諾登,美國實際上已有思想準備「無法引渡」史諾登,中方應創造條件讓美方最終放棄引渡的希望,避免美方將希望寄託在對香港和北京施加愈來愈大的壓力上。 Read more: 世界新聞網-北美華文新聞、華商資訊 - 中國官媒 引渡史諾登 中港都丟臉

    This input i need exact perl length..that decode_entities not working

      The problem seems not to be with HTML::Entities:

      > perl -MHTML::Entities=decode_entities -e "print length decode_entiti +es('&#31038;&#35542;')" 2

      As you've been told before, you will need to find out what encoding the browser uses to send your input data to your script. This is not necessarily easy to enforce. One good approach is to use <meta http-equiv="Content-Type" ... tags on every HTML page, no matter where it is served from.

        Thank u ..I Got the output...

      I see no entities that would need decoding. What exact output did you expect? What exact output did you get?

      Without knowing what you want, it is hard to know how to get there.

        Thank u ..I Got the output...

        use HTML::Entities; use Encode; my $first_name_assign="$firstname"; $first_name_assign=decode('UTF-8',$first_name_assign); $first_name_assign=decode_entities($first_name_assign); my $first_name_length=length($first_name_assign); print "$first_name_length";

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2019-04-26 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I am most likely to install a new module from CPAN if:
















    Results (129 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!