develooper Front page | perl.perl5.porters | Postings from July 2009

Re: [perl #63574] funny results from ~ on non-Latin-1 string

Thread Next
Yitzchak Scott-Thoennes
July 16, 2009 20:49
Re: [perl #63574] funny results from ~ on non-Latin-1 string
Message ID:
Zefram wrote:
> ~ is documented to operate on integers or bit strings, but "\x{aaa}"
> is neither.  Empirically, if ~ is applied to a string containing at least
> one non-octet, the result is a string of the same length, where each
> codepoint is equal to 0xffffffff minus an input codepoint.  That could
> conceivably be a useful operation, if it could be consistently applied
> to all strings, but if all input codepoints are 0xff or below then ~
> negates octets rather than 32-bit codepoints.  ~~$_ eq $_ is broken for
> values such as "\x{ffffffaa}".

Not a bug.

The existing behavior was Jarkko's call during 5.7.x development, though it
seems to have escaped being documented.


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About