i have a character $string="€"; when use below javascript to encode it
i will be given a 7 byte stirng like this $encoded_result= "€"
i want to know if there is the equevelent of module or code in perl which do the same task , turn $string="€"; into $encoded_result= "€" ?
Code:
<SCRIPT type=text/javascript>
function ConvUtf(obj,btn){
document.getElementById("result").value=obj.value.replace(/[^\u0000-\u00FF]/g,function($0){return escape($0).replace(/(%u)(\w{4})/gi,"&#x$2;")});
}
function ResChinese(obj,btn)
{
document.getElementById("content").value=unescape(obj.value.replace(/&#x/g,'%u').replace(/;/g,''));
}
</SCRIPT>
I have asked perl guru . some of them mentioned HTML::Entities
however from my testing i can't get the expecting result
here is the code i tested and its output is "€"
#!/usr/bin/perl
#use HTML::Entities;
use HTML::Entities"encode_entities_numeric";
$string="€"; # ("€" expected result)
$encoded_result= encode_entities_numeric($string);
print $encoded_result;
is there anything i miss? or is there any code i could use to make such a encode?
Thanks in advance