/[classpath]/classpath/gnu/java/nio/charset/UTF_16Decoder.java
ViewVC logotype

Diff of /classpath/gnu/java/nio/charset/UTF_16Decoder.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by tromey, Fri Apr 23 21:13:20 2004 UTC revision 1.3.2.1 by gnu_andrew, Mon Apr 18 01:37:36 2005 UTC
# Line 55  final class UTF_16Decoder extends Charse Line 55  final class UTF_16Decoder extends Charse
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;
# Line 83  final class UTF_16Decoder extends Charse Line 83  final class UTF_16Decoder extends Charse
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;
# Line 104  final class UTF_16Decoder extends Charse Line 104  final class UTF_16Decoder extends Charse
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    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.3.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26