55 |
static final int LITTLE_ENDIAN = 1; |
static final int LITTLE_ENDIAN = 1; |
56 |
static final int UNKNOWN_ENDIAN = 2; |
static final int UNKNOWN_ENDIAN = 2; |
57 |
|
|
58 |
private static final char BYTE_ORDER_MARK = '\uFEFF'; |
private static final char BYTE_ORDER_MARK = 0xFEFF; |
59 |
private static final char REVERSED_BYTE_ORDER_MARK = '\uFFFE'; |
private static final char REVERSED_BYTE_ORDER_MARK = 0xFFFE; |
60 |
|
|
61 |
private final int originalByteOrder; |
private final int originalByteOrder; |
62 |
private int byteOrder; |
private int byteOrder; |
83 |
// handle byte order mark |
// handle byte order mark |
84 |
if (byteOrder == UNKNOWN_ENDIAN) |
if (byteOrder == UNKNOWN_ENDIAN) |
85 |
{ |
{ |
86 |
char c = (char) ((b1 << 8) | b2); |
char c = (char) (((b1 & 0xFF) << 8) | (b2 & 0xFF)); |
87 |
if (c == BYTE_ORDER_MARK) |
if (c == BYTE_ORDER_MARK) |
88 |
{ |
{ |
89 |
byteOrder = BIG_ENDIAN; |
byteOrder = BIG_ENDIAN; |
104 |
} |
} |
105 |
} |
} |
106 |
|
|
107 |
|
// FIXME: Change so you only do a single comparison here. |
108 |
char c = byteOrder == BIG_ENDIAN ? (char) ((b1 << 8) | b2) |
char c = byteOrder == BIG_ENDIAN ? (char) ((b1 << 8) | b2) |
109 |
: (char) ((b2 << 8) | b1); |
: (char) ((b2 << 8) | b1); |
110 |
|
|