I have a Byte comparison failing in Oxygene that was really confusing me. The byte being read in is a paragraph marker in MacRoman encoding, byte value 166. I was reading this into a Byte, which displayed in the debugger as -90 due to the signing issue. I created a byte var to represent the paragraph marker
const kParagraphMarker = chr(166); // actually defined elsewhere in codebase var paragraphMarker := Byte(kParagraphMarker);
This also displays in the debugger as -90, but when I do a comparison
(aByte = paragraphMarker) the comparison fails. I tried casting to
Char and one was 166 while the other was 65k. When I cast to Integer both are 166.
It occurred to me that this could be something similar to Java’s primitive wrappers, where
int is a primitive and
Integer is a wrapper object for it, so the
= operator is actually a reference comparison rather than a value comparison, which may fail unpredictably due to internal caching mechanisms. So I tried
aByte.equals(paragraphMarker) and it worked correctly.
I have byte comparisons throughout my codebase that use the
= operator. These operations previously worked and now do not. Is this an intended change? If so, is there a way around it without having to find and change all of my byte comparisons using the
= operator? (I have many, many of these in my codebase as there are a lot of low-level text/char operations)