Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

language Decoding problem..?

by vasanthgk91 (Sexton)
on May 17, 2013 at 10:08 UTC ( #1033959=perlquestion: print w/ replies, xml ) Need Help??
vasanthgk91 has asked for the wisdom of the Perl Monks concerning the following question:

my $title_checking=$cgi->param("title_checking");

This $title_checking scalar variable via coming other language content

use HTML::Entities; my $titlenamefromindex="ஸ்ரீசா&#xB +A8;்த், சவான், &#xB9A +;ண்டிலா ஆகி&#xB +AF;ோர் தங்களத&# +xBC1; குற்றங்கள +ை ஒப்புக் க&#xB +CA;ண்டதாக தகவ&# +xBB2;்"; $titlenamefromindex=encode_entities($titlenamefromindex,"\200-\377");

This $titlenamefromindex variable via i got the original content

if($title_checking eq $titlenamefromindex) { condition; }

I know that $title_checking param value and $titlenamefromindex value equal..But not executing Any mistake is there I did please give suggestion.

Comment on language Decoding problem..?
Select or Download Code
Re: language Decoding problem..?
by space_monk (Chaplain) on May 17, 2013 at 10:35 UTC

    Are you definitely sure they are equal? One stray space or punctuation mark is all it would take for them to be different.

    You should use modules such as Data::Dumper to find out, and perhaps reverse encode title_checking to see if you end up with the same entities.

    If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)

      In header section I used properly Meta content

      <meta http-equiv=\"content-type\" content=\"text/ html; charset=UT +F-8\">

      In form section also i used properly utf-8

      <form accept-charset=\"utf-8\"></form>

      Next page param receiving

      my $title_checking=$cgi->param("title_checking"); print "$title_checking";

      ஸ்ரீசாந்த், சவான், சண்டிலா ஆகியோர் தங்களது குற்றங்களை ஒப்புக் கொண்டதாக தகவல் Like that i receiving

        I suggest just to be sure you walk along each character to find the difference. Something like this:
        # there are probably better ways of doing a string diff... my ($s1, $s2) = ($title_checking, $titlenamefromindex); for (my $i = 0; i < length( $s1); $i++) { print "Different at $i\n" if (substr( $s1, $i, 1) ne substr( $s2, $ +i, 1); }
        (You may need to make minor fixes to above)
        If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)
Re: language Decoding problem..?
by moritz (Cardinal) on May 17, 2013 at 15:33 UTC
Re: language Decoding problem..?
by farang (Hermit) on May 17, 2013 at 17:02 UTC

    I think you may want to first decode the HTML and then encode the string as UTF-8.

    use strict; use warnings; use HTML::Entities; use Encode 'encode'; my $titlenamefromindex=q{&#xBB8;&#xBCD;&#xBB0;&#xBC0;&#xB9A;&#xBBE;&#x +BA8;&#xBCD;&#xBA4;&#xBCD;, &#xB9A;&#xBB5;&#xBBE;&#xBA9;&#xBCD;, &#xB9 +A;&#xBA3;&#xBCD;&#xB9F;&#xBBF;&#xBB2;&#xBBE; &#xB86;&#xB95;&#xBBF;&#x +BAF;&#xBCB;&#xBB0;&#xBCD; &#xBA4;&#xB99;&#xBCD;&#xB95;&#xBB3;&#xBA4;& +#xBC1; &#xB95;&#xBC1;&#xBB1;&#xBCD;&#xBB1;&#xB99;&#xBCD;&#xB95;&#xBB3 +;&#xBC8; &#xB92;&#xBAA;&#xBCD;&#xBAA;&#xBC1;&#xB95;&#xBCD; &#xB95;&#x +BCA;&#xBA3;&#xBCD;&#xB9F;&#xBA4;&#xBBE;&#xB95; &#xBA4;&#xB95;&#xBB5;& +#xBB2;&#xBCD}; $titlenamefromindex = decode_entities($titlenamefromindex); print encode('UTF-8', $titlenamefromindex ), "\n";

    Output:
    ஸ்ரீசாந்த், சவான், சண்டிலா ஆகியோர் தங்களது குற்றங்களை ஒப்புக் கொண்டதாக தகவல்

      thank u

      use HTML::Entities; use Encode; my $title_checking=$cgi->param("title_checking"); $title_checking=decode_entities($title_checking); $title_checking=encode('UTF-8',$title_checking); $title_checking=$prl->trim($title_checking); print "$title_checking";

      It's working...In my server I stored this format value then compare it's working..great thanks

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2014-12-27 23:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls