in reply to Re^2: perplexing inconsistency using RC4 and unpack
in thread perplexing inconsistency using RC4 and unpack

You are suffering from UTF-8 expansion:

#!/usr/bin/perl -wl print unpack "U0H*", "\x{BF}"; print unpack "U0H*", "\x{FF}"; print unpack "U0H*", "\x{FA}"; __END__ c2bf c3bf c3ba

Now you just need to figure out where the UTF-8 expansion is sneaking in.

- tye        

Replies are listed 'Best First'.
Re^4: perplexing inconsistency using RC4 and unpack (UTF-8)
by oddmedley (Novice) on Aug 01, 2009 at 14:44 UTC
    thank you tye, that was extremely helpful. seems I had an issue with a blank string being converted to a hash somewhere in an XML parsing phase, which was later cast to a string (which seemed to make perl guess it was a UTF8 one). several concatenations later what looked like a nice plan ascii string, actually wasn't. the solution? specify my input more rigorously:
    if($options->{'customerpass'} && (ref $options->{'customerpass'} ne +"HASH")){ $options->{'customerpass'} = encode("iso-8859-1", $options->{'cust +omerpass'}); }else{ $options->{'customerpass'} = ''; }
    leaves nothing to guess work and fixed my problem. (this call to encode ( use Encode; ) basically says (I think), 'whatever it looks like, this string is latin1 ascii, end of story.' no more utf8 expansion!)
    thanks for the help!