Guessing that "sign overstruck numbers" means that the sign of a string
of digits is embedded into the first digit, rather than consuming
an "extra" character position in fixed width fields, then there wouldn't
be a string of them, but a string might have one of them in the
first position.
Except for the "{", there is a bit-pattern relationship to these
characters, which could be converted via the use of logical bitwise
operators. Assuming $string contains a string of digits, except the
first might be one of these sign overstruck numbers, and that "{" is
replaced by "@" to make the bit-pattern relationship consistent, then
the conversion of string to a "normal" numeric value could proceed
as follows:
$string = '-' . chr(ord(substr($string,0,1)) ^ 0x70) . substr (
$string, 1 )
if ord(substr($string,0,1)) >= 0x40;
With "{" in the set, there is no _simple_ conversion using logical
bitwise operators.
Note that a very similar routine (the magic of XOR) could convert it
back:
$string = chr(ord(substr($string,1,1)) ^ 0x70) . substr ( $string, 2 )
if substr($string,0,1) == '-';
"$Bill Luebkert" wrote:
> Dirk Bremer wrote:
> >
> > I would like to do something simple with a ^, |, or & to translate sign-overstruck
>characters to their corresponding numeric values
> > and vice versa. For example, the sign-overstruck characters equals the following
>numbers:
> >
> > { = -0
> > A = -1
> > B = -2
> > C = -3
> > D = -4
> > E = -5
> > F = -6
> > G = -7
> > H = -8
> > I = -9
> >
> > How can I do this with Perl's bitwise operators?
>
> I have no idea what sign-overstruck characters are. Are these the only
> ten possible combinations? Are they single letters or can you get a
> string of them? The logical thing to do is use a hash to convert them.
> Or in a string of them, a RE with /eg modifiers to convert them.
>
> --
> ,-/- __ _ _ $Bill Luebkert ICQ=14439852
> (_/ / ) // // DBE Collectibles http://www.todbe.com/
> / ) /--< o // // Mailto:[EMAIL PROTECTED] http://dbecoll.webjump.com/
> -/-' /___/_<_</_</_ http://www.freeyellow.com/members/dbecoll/
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
--
Glenn
=====
Due to the current economic situation, the light at the end of the
tunnel
will be turned off until further notice.
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users