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
This commit is contained in:
Abhinav Gupta 2011-10-24 19:24:08 +00:00
parent e35f720425
commit 1efa6d411f
3 changed files with 4 additions and 4 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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<CollationKey>
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) {