From: Abhinav Gupta Date: Mon, 24 Oct 2011 19:24:08 +0000 (+0000) Subject: ICU-8854 bitwise and/or of signed byte value. X-Git-Tag: milestone-59-0-1~4392 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1efa6d411f9607c41a1dfe10093cb81f7bf30a17;p=icu ICU-8854 bitwise and/or of signed byte value. Values loaded from a byte array are sign extended to 32-bits before any bitwise operations are performed. Should &-down back to one-byte. X-SVN-Rev: 30862 --- diff --git a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetISCII.java b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetISCII.java index b33e4025e4d..531ccdaf53f 100644 --- a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetISCII.java +++ b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetISCII.java @@ -1234,7 +1234,7 @@ class CharsetISCII extends CharsetICU { /* Write the language code following LF only if LF is not the last character. */ if (fromUnicodeStatus == LF) { targetByteUnit = ATR << 8; - targetByteUnit += (byte)lookupInitialData[range].isciiLang; + targetByteUnit += 0xff & (byte)lookupInitialData[range].isciiLang; fromUnicodeStatus = 0x0000; /* now append ATR and language code */ cr = WriteToTargetFromU(offsets, source, target, targetByteUnit); diff --git a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetMBCS.java b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetMBCS.java index 0d384369dfd..9a1ec64a548 100644 --- a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetMBCS.java +++ b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetMBCS.java @@ -623,7 +623,7 @@ class CharsetMBCS extends CharsetICU { int st1, st2, st3, i; for (st1 = 0; stageUTF8Index < stageUTF8Length; ++st1) { - st2 = ((char)stage[2*st1]<<8) | stage[2*st1+1]; + st2 = ((char)stage[2*st1]<<8) | (0xff & stage[2*st1+1]); if (st2 != stage1Length/2) { /* each stage 2 block has 64 entries corresponding to 16 entries in the mbcsIndex */ for (i = 0; i < 16; ++i) { diff --git a/icu4j/main/classes/collate/src/com/ibm/icu/text/CollationKey.java b/icu4j/main/classes/collate/src/com/ibm/icu/text/CollationKey.java index fddd61cb0a1..ab747a1ad50 100644 --- a/icu4j/main/classes/collate/src/com/ibm/icu/text/CollationKey.java +++ b/icu4j/main/classes/collate/src/com/ibm/icu/text/CollationKey.java @@ -1,6 +1,6 @@ /** ******************************************************************************* -* Copyright (C) 1996-2010, International Business Machines Corporation and * +* Copyright (C) 1996-2011, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -345,7 +345,7 @@ public final class CollationKey implements Comparable StringBuilder key = new StringBuilder(size); int i = 0; while (m_key_[i] != 0 && m_key_[i + 1] != 0) { - key.append((char)((m_key_[i] << 8) | m_key_[i + 1])); + key.append((char)((m_key_[i] << 8) | (0xff & m_key_[i + 1]))); i += 2; } if (m_key_[i] != 0) {