### 7bit ascii equal parity posing problems

by bear0053 (Hermit)
 on Mar 02, 2004 at 21:34 UTC Need Help??
bear0053 has asked for the wisdom of the Perl Monks concerning the following question:

fellow monks i have come across a situation that baffeled me.

i have an encryption object running from win32 that returns binary data in 7 bit Ascii (verified in .NET). When perl gets the property from the object and puts the value into a scalar it converts it to binary 7 bit ascii "even" parity. when .NET applications read this data from the encryption object it is simply read in as 7 bit ascii. why is this happening and what can i do to fore it in as 7 bit ascii?

EXAMPLE:
in .NET C# object returns an EOT Hex 04 in 7 bit ascii

in perl the object returns EOT Hex 84 in 7 bit ascii even parity

WHY?
can it be forced to 7 bit ascii or can i convert the 7 bit ascii even parity to 7 bit ascii easily?

the convert route is not optimal for performance, the cpu is already hit from the auto conversion to 7 bit ascii even parity.

• Comment on 7bit ascii equal parity posing problems

Replies are listed 'Best First'.
Re: 7bit ascii equal parity posing problems
by Stevie-O (Friar) on Mar 03, 2004 at 00:10 UTC
Not having seen your code, I have no idea why anything is doing anything :) But I can provide you with this little snippet:
```\$str &= ("\177" x length \$str);
That will remove the 8th bit from every character in \$str.
--Stevie-O
```\$"=\$,,\$_=q>|\p4<6 8p<M/_|<('=>
.q>.<4-KI<l|2\$<6%s!<qn#F<>;\$,
.=pack'N*',"@{[unpack'C*',\$_]
}"for split/</;\$_=\$,,y[A-Z a-z]
{}cd;print lc
i am using a Win32::OLE object that works like this:
```my \$obj =  lockpan(); //interacts with a vb6 dll
my \$enc_data = obj->encryptval(\$data); //returns binary val
\$enc_data = '0x' . unpack('H*', \$enc_data); //bin -> hex
#\$enc_data is then written to a sql db
when the code is stored it is stored a 7 bit ascii even parity. so some how perl takes 7 bit ascii and turns it into 7 bit ascii even parity. why and how can i stop this?
Re: 7bit ascii equal parity posing problems
by Roger (Parson) on Mar 03, 2004 at 00:31 UTC
I am guessing that you are using Win32::OLE? Have a look at the property get's character code conversion page option. You can have the following code pages: CP_ACP CP_OEMCP CP_MACCP CP_UTF7 CP_UTF8. The default code page is CP_ACP, but you could try the CP_OEMCP to modify its character conversion behaviour. I haven't seen your code, so this is just a guess.

Create A New User
Node Status?
node history
Node Type: perlquestion [id://333378]
Approved by Wally Hartshorn
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2018-11-17 06:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My code is most likely broken because:

Results (202 votes). Check out past polls.

Notices?