Hi,
Can somebody let me know how to declare a scalar variable as a ³Unicode
symbol² say for example
$char=¹©¹;
I know the following declarations but was not able to find for Unicode
(ascii) symbols.
.23E-10 # a very small number
3.14_15_92 # a very important number
4_294_967_296 # underscore for legibility
0xff # hex
0xdead_beef # more hex
0377 # octal
0b011011 # binary
All I am trying to do is search for unicode symbols in a file and convert
them into corresponding Hex value.
Something like below:
!#usr/bin/perl -w
open (IN, "$ARGV[0]");
undef $/;
$_=<IN>;
$file=$_;
$char='©';
if($file=~m/$char/g)
{
$decval = ord $char;
sprintf("&#%.5x;", $decval) ;
}
open (OUT,">$ARGV[0]");
print OUT $file;
close(OUT);
close(IN);
I believe that this code is secure one as I am working on an XML document.
Thanks for help.
Pankaj
On 9/17/07 9:10 PM, " merlyn%40stonehenge.com">merlyn
stonehenge.com" < merlyn%40stonehenge.com">merlyn
stonehenge.com> wrote:
>
>
>
>
>>>>>> >>>>> "Thiago" == Thiago Nascimento < nascimenthiago%40gmail.com">nascimenthiago
gmail.com
>>>>>> <mailto:nascimenthiago%40gmail.com> > writes:
>
> Thiago> my $char = '(c)';
> Thiago> my $decval = ord $char;
>
> That's not really "decimal". It's just a "number" internally, without a
> numeric base. Well, technically, it's represented in IEEE Floating Point, but
> you probably don't care about that. The only time it becomes "decimal" is
> when it gets printed, where it is sent automatically through "number to
> decimal" conversions.
>
> Thiago> my $hexval = sprintf("%x", $decval);
>
> So this is a "number to hex" conversion, not a decimal to hex conversion.
>
> Just trying to get the terminology nailed down, because misstating it
> at this level can lead to bizarre conclusions.
[Non-text portions of this message have been removed]