in reply to convert 7 bit even parity to 7 bit ascii

What the heck is "7 bit even parity"? What is the real problem you are having? Are you getting bytes with the high bit set when you are expecting only ASCII? Where is data coming from? Perl deals with strings containing 8-bit bytes. It does not do any conversion (unless you are doing Unicode).

My guess is that this is an encoding problem. 0x84 is DOUBLE LOW-9 QUOTATION MARK in CP1252. CP1252 is a common character set with Windows adds smart quotes and other stuff to Latin-1. My suspicion is that the data you are decoding is a string containing a smart quote. If you want 7-bit ASCII, then you will need to strip or convert the 8-bit bytes.

  • Comment on Re: convert 7 bit even parity to 7 bit ascii

Replies are listed 'Best First'.
Re: Re: convert 7 bit even parity to 7 bit ascii
by bear0053 (Hermit) on Mar 09, 2004 at 22:40 UTC
    ok here it is:
    a com object returns a binary string to perl in ascii 7 bit (8 bit for popular terms)

    perl converts this binary to ascii 7 bit even parity by default when the com objects return value is set to a scalar.
    binary data from com object looks something like this:
    79a30bf0ac64fc0e469f0568562e43e53f89a3f46f7437d44d96dcd5087b20056df7fcb07485f0c0 (7 bit ascii even parity)

    the same com object used in .net or asp returns binary value in ascii 7 bit (8bit for popular term)

    i can't have this happen becuase the two systems won't decrypt the same value correctly through the com object.

    some Hex values in ascii 7 bit even parity represent chars differently compared to the Hex representation of the same character in 7 bit ascii

    I need to find a way for perl not to transfer the binary string returned from the com object into 7 bit even parity. this changes the hex values thus cannot be converted correctly by the .net apps that read in the perl stored values.

      The easy was to convert from data+parity to data is to & your input with 0x7F. Note that this destroys any benifit the parity might have (in this case, none).

      If you've got a bunch of data in $data, and want to strip the high bit, try $data = chr(0x7F) x length($data);.

      Note that I suspect your actual problem has little to do with parity vs non-parity, but rather with utf-8 encoding. I know of nowhere in perl that cares about parity.


      Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

      What is the data from the COM object supposed to look like? Are you certain it is 7-bit ASCII with no bytes with the high bit set? In other words, with no extended characters in it.

      Perl is almost certainly not converting to "7-bit even parity" because it doesn't know about any such thing. The only place I have seen "even parity" used is with modems. Not to mention that the string you presented is not even partity.

      That string is not in UTF-8 but it is still likely an encoding issue. Win32::OLE does have an option to set the code page for translating Unicode strings to Perl strings. You might want to check its value or explicitly set it the code page.

      why was this node voted down???