private Reader bom(InputStream is,char hint) throws Exception {
  int val=is.read();
switch (val) {
case 0xef:
    if (hint == 'U') {
      panic(FAULT);
    }
  if (is.read() != 0xbb) {
    panic(FAULT);
  }
if (is.read() != 0xbf) {
  panic(FAULT);
}
return new ReaderUTF8(is);
case 0xfe:
if (is.read() != 0xff) {
panic(FAULT);
}
return new ReaderUTF16(is,'b');
case 0xff:
if (is.read() != 0xfe) {
panic(FAULT);
}
return new ReaderUTF16(is,'l');
case -1:
mChars[mChIdx++]=EOS;
return new ReaderUTF8(is);
default :
if (hint == 'U') {
panic(FAULT);
}
switch (val & 0xf0) {
case 0xc0:
case 0xd0:
mChars[mChIdx++]=(char)(((val & 0x1f) << 6) | (is.read() & 0x3f));
break;
case 0xe0:
mChars[mChIdx++]=(char)(((val & 0x0f) << 12) | ((is.read() & 0x3f) << 6) | (is.read() & 0x3f));
break;
case 0xf0:
throw new UnsupportedEncodingException();
default :
mChars[mChIdx++]=(char)val;
break;
}
return null;
}
}

private Reader bom ( InputStream is , char hint ) throws Exception { int val = is . read ( ) ; switch ( val ) { case 0xef : if ( hint == 'U' ) { panic ( FAULT ) ; } if ( is . read ( ) != 0xbb ) { panic ( FAULT ) ; } if ( is . read ( ) != 0xbf ) { panic ( FAULT ) ; } return new ReaderUTF8 ( is ) ; case 0xfe : if ( is . read ( ) != 0xff ) { panic ( FAULT ) ; } return new ReaderUTF16 ( is , 'b' ) ; case 0xff : if ( is . read ( ) != 0xfe ) { panic ( FAULT ) ; } return new ReaderUTF16 ( is , 'l' ) ; case - 1 : mChars [ mChIdx ++ ] = EOS ; return new ReaderUTF8 ( is ) ; default : if ( hint == 'U' ) { panic ( FAULT ) ; } switch ( val & 0xf0 ) { case 0xc0 : case 0xd0 : mChars [ mChIdx ++ ] = ( char ) ( ( ( val & 0x1f ) << 6 ) | ( is . read ( ) & 0x3f ) ) ; break ; case 0xe0 : mChars [ mChIdx ++ ] = ( char ) ( ( ( val & 0x0f ) << 12 ) | ( ( is . read ( ) & 0x3f ) << 6 ) | ( is . read ( ) & 0x3f ) ) ; break ; case 0xf0 : throw new UnsupportedEncodingException ( ) ; default : mChars [ mChIdx ++ ] = ( char ) val ; break ; } return null ; } }
determines the entity encoding . this method gets encoding from byte order mask [ # 4 . 3 . 3 ] if any . note , the first byte returned by the entity ' s byte stream has to be the first byte in the entity . also , there is no support for ucs - 4 .
