List Info

Thread: Re: Ascii to hexavalue and decimal




Re: Ascii to hexavalue and decimal
country flaguser name
United States
2007-09-18 02:17:07

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">merlynstonehenge.com"; < merlyn%40stonehenge.com">merlynstonehenge.com> wrote:

>
>
>
>
>>;>>&gt;> >>&gt;>> "Thiago" == Thiago Nascimento < nascimenthiago%40gmail.com">nascimenthiagogmail.com
>>;>>&gt;> <mailto:nascimenthiago%40gmail.com> > writes:
>
> Thiago> my $char = '(c)';
&gt; Thiago> my $decval = ord $char;
&gt;
> 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&quot; conversions.
>
> Thiago> my $hexval = sprintf(&quot;%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]

__._,_.___
Recent Activity
Visit Your Group
Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

Search Ads

Get new customers.

List your web site

in Yahoo! Search.

Yoga Resources

on Yahoo! Groups

Take the stress

out of your life.

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )