public boolean skipChar(int ch) throws EOFExceptionHuge, EncodingExceptionHuge, ParseExceptionHuge { int temp = (xb.byteAt(offset+1)&0xff) << 8 | (xb.byteAt(offset)&0xff); if (temp < 0xd800 ||temp > 0xdfff) { // check for low surrogate if (temp == ch) { offset += 2; return true; } else { return false; } } else { if (temp<0xd800 || temp>0xdbff) throw new EncodingExceptionHuge("UTF 16 LE encoding error: should never happen"); int val = temp; temp = (xb.byteAt(offset+3)&0xff)<< 8 | (xb.byteAt(offset+2)&0xff); if (temp < 0xdc00 || temp > 0xdfff) { // has to be high surrogate throw new EncodingExceptionHuge("UTF 16 LE encoding error: should never happen"); } val = ((val - 0xd800)<<10) + (temp - 0xdc00) + 0x10000; if (val == ch) { offset += 4; return true; } else return false; } } }
public boolean skipChar(int ch) throws EOFExceptionHuge, EncodingExceptionHuge, ParseExceptionHuge { int temp = (xb.byteAt(offset+1)&0xff) << 8 | (xb.byteAt(offset)&0xff); if (temp < 0xd800 ||temp > 0xdfff) { // check for low surrogate if (temp == ch) { offset += 2; return true; } else { return false; } } else { if (temp<0xd800 || temp>0xdbff) throw new EncodingExceptionHuge("UTF 16 LE encoding error: should never happen"); int val = temp; temp = (xb.byteAt(offset+3)&0xff)<< 8 | (xb.byteAt(offset+2)&0xff); if (temp < 0xdc00 || temp > 0xdfff) { // has to be high surrogate throw new EncodingExceptionHuge("UTF 16 LE encoding error: should never happen"); } val = ((val - 0xd800)<<10) + (temp - 0xdc00) + 0x10000; if (val == ch) { offset += 4; return true; } else return false; } } }
public boolean skipChar(int ch) throws EOFExceptionHuge, ParseExceptionHuge, EncodingExceptionHuge { // implement UTF-16BE to UCS4 conversion int temp = (xb.byteAt(offset)&0xff) << 8 | (xb.byteAt(offset+1)&0xff); if ((temp < 0xd800) || (temp > 0xdfff)) { // not a high surrogate //offset += 2; if (temp == ch) { offset += 2; return true; } else return false; } else { if (temp<0xd800 || temp>0xdbff) throw new EncodingExceptionHuge("UTF 16 BE encoding error: should never happen"); int val = temp; temp = (xb.byteAt(offset+2)&0xff) << 8 | (xb.byteAt(offset+3)&0xff); if (temp < 0xdc00 || temp > 0xdfff) { // has to be a low surrogate here throw new EncodingExceptionHuge("UTF 16 BE encoding error: should never happen"); } val = ((val - 0xd800) << 10) + (temp - 0xdc00) + 0x10000; if (val == ch) { offset += 4; return true; } else return false; } } }
public boolean skipChar(int ch) throws EOFExceptionHuge, EncodingExceptionHuge, ParseExceptionHuge { int temp = (xb.byteAt(offset+1)&0xff) << 8 | (xb.byteAt(offset)&0xff); if (temp < 0xd800 ||temp > 0xdfff) { // check for low surrogate if (temp == ch) { offset += 2; return true; } else { return false; } } else { if (temp<0xd800 || temp>0xdbff) throw new EncodingExceptionHuge("UTF 16 LE encoding error: should never happen"); int val = temp; temp = (xb.byteAt(offset+3)&0xff)<< 8 | (xb.byteAt(offset+2)&0xff); if (temp < 0xdc00 || temp > 0xdfff) { // has to be high surrogate throw new EncodingExceptionHuge("UTF 16 LE encoding error: should never happen"); } val = ((val - 0xd800)<<10) + (temp - 0xdc00) + 0x10000; if (val == ch) { offset += 4; return true; } else return false; } } }
public boolean skipChar(int ch) throws EOFExceptionHuge, ParseExceptionHuge, EncodingExceptionHuge { // implement UTF-16BE to UCS4 conversion int temp = (xb.byteAt(offset)&0xff) << 8 | (xb.byteAt(offset+1)&0xff); if ((temp < 0xd800) || (temp > 0xdfff)) { // not a high surrogate //offset += 2; if (temp == ch) { offset += 2; return true; } else return false; } else { if (temp<0xd800 || temp>0xdbff) throw new EncodingExceptionHuge("UTF 16 BE encoding error: should never happen"); int val = temp; temp = (xb.byteAt(offset+2)&0xff) << 8 | (xb.byteAt(offset+3)&0xff); if (temp < 0xdc00 || temp > 0xdfff) { // has to be a low surrogate here throw new EncodingExceptionHuge("UTF 16 BE encoding error: should never happen"); } val = ((val - 0xd800) << 10) + (temp - 0xdc00) + 0x10000; if (val == ch) { offset += 4; return true; } else return false; } } }
public boolean skipChar(int ch) throws EOFExceptionHuge, ParseExceptionHuge, EncodingExceptionHuge { // implement UTF-16BE to UCS4 conversion int temp = (xb.byteAt(offset)&0xff) << 8 | (xb.byteAt(offset+1)&0xff); if ((temp < 0xd800) || (temp > 0xdfff)) { // not a high surrogate //offset += 2; if (temp == ch) { offset += 2; return true; } else return false; } else { if (temp<0xd800 || temp>0xdbff) throw new EncodingExceptionHuge("UTF 16 BE encoding error: should never happen"); int val = temp; temp = (xb.byteAt(offset+2)&0xff) << 8 | (xb.byteAt(offset+3)&0xff); if (temp < 0xdc00 || temp > 0xdfff) { // has to be a low surrogate here throw new EncodingExceptionHuge("UTF 16 BE encoding error: should never happen"); } val = ((val - 0xd800) << 10) + (temp - 0xdc00) + 0x10000; if (val == ch) { offset += 4; return true; } else return false; } } }
public int getChar() throws EOFExceptionHuge, ParseExceptionHuge, EncodingExceptionHuge { int val = 0; if (offset >= endOffset) throw new EOFExceptionHuge("permature EOF reached, XML document incomplete"); int temp = (xb.byteAt(offset+1) &0xff) << 8 | (xb.byteAt(offset)& 0xff); if (temp < 0xd800 || temp > 0xdfff) { // check for low surrogate offset += 2; return temp; } else { if (temp<0xd800 || temp>0xdbff) throw new EncodingExceptionHuge("UTF 16 LE encoding error: should never happen"); val = temp; temp = (xb.byteAt(offset+3) &0xff) << 8 | (xb.byteAt(offset+2)&0xff); if (temp < 0xdc00 || temp > 0xdfff) { // has to be high surrogate throw new EncodingExceptionHuge("UTF 16 LE encoding error: should never happen"); } val = ((val - 0xd800) <<10) + (temp - 0xdc00) + 0x10000; offset += 4; return val; } } public boolean skipChar(int ch)
public int getChar() throws EOFExceptionHuge, ParseExceptionHuge, EncodingExceptionHuge { int val = 0; if (offset >= endOffset) throw new EOFExceptionHuge("permature EOF reached, XML document incomplete"); int temp = (xb.byteAt(offset+1) &0xff) << 8 | (xb.byteAt(offset)& 0xff); if (temp < 0xd800 || temp > 0xdfff) { // check for low surrogate offset += 2; return temp; } else { if (temp<0xd800 || temp>0xdbff) throw new EncodingExceptionHuge("UTF 16 LE encoding error: should never happen"); val = temp; temp = (xb.byteAt(offset+3) &0xff) << 8 | (xb.byteAt(offset+2)&0xff); if (temp < 0xdc00 || temp > 0xdfff) { // has to be high surrogate throw new EncodingExceptionHuge("UTF 16 LE encoding error: should never happen"); } val = ((val - 0xd800) <<10) + (temp - 0xdc00) + 0x10000; offset += 4; return val; } } public boolean skipChar(int ch)
public int getChar() throws EOFExceptionHuge, ParseExceptionHuge, EncodingExceptionHuge { int val = 0; if (offset >= endOffset) throw new EOFExceptionHuge("permature EOF reached, XML document incomplete"); int temp = (xb.byteAt(offset)&0xff) << 8 | (xb.byteAt(offset+1)&0xff); if ((temp < 0xd800) || (temp > 0xdfff)) { // not a high surrogate offset += 2; return temp; } else { if (temp<0xd800 || temp>0xdbff) throw new EncodingExceptionHuge("UTF 16 BE encoding error: should never happen"); val = temp; temp = (xb.byteAt(offset+2)&0xff) << 8 | (xb.byteAt(offset+3)&0xff); if (temp < 0xdc00 || temp > 0xdfff) { // has to be a low surrogate here throw new EncodingExceptionHuge("UTF 16 BE encoding error: should never happen"); } val = ((val - 0xd800)<<10) + (temp - 0xdc00) + 0x10000; offset += 4; return val; } } public boolean skipChar(int ch)
public int getChar() throws EOFExceptionHuge, ParseExceptionHuge, EncodingExceptionHuge { int val = 0; if (offset >= endOffset) throw new EOFExceptionHuge("permature EOF reached, XML document incomplete"); int temp = (xb.byteAt(offset+1) &0xff) << 8 | (xb.byteAt(offset)& 0xff); if (temp < 0xd800 || temp > 0xdfff) { // check for low surrogate offset += 2; return temp; } else { if (temp<0xd800 || temp>0xdbff) throw new EncodingExceptionHuge("UTF 16 LE encoding error: should never happen"); val = temp; temp = (xb.byteAt(offset+3) &0xff) << 8 | (xb.byteAt(offset+2)&0xff); if (temp < 0xdc00 || temp > 0xdfff) { // has to be high surrogate throw new EncodingExceptionHuge("UTF 16 LE encoding error: should never happen"); } val = ((val - 0xd800) <<10) + (temp - 0xdc00) + 0x10000; offset += 4; return val; } } public boolean skipChar(int ch)
public int getChar() throws EOFExceptionHuge, ParseExceptionHuge, EncodingExceptionHuge { int val = 0; if (offset >= endOffset) throw new EOFExceptionHuge("permature EOF reached, XML document incomplete"); int temp = (xb.byteAt(offset)&0xff) << 8 | (xb.byteAt(offset+1)&0xff); if ((temp < 0xd800) || (temp > 0xdfff)) { // not a high surrogate offset += 2; return temp; } else { if (temp<0xd800 || temp>0xdbff) throw new EncodingExceptionHuge("UTF 16 BE encoding error: should never happen"); val = temp; temp = (xb.byteAt(offset+2)&0xff) << 8 | (xb.byteAt(offset+3)&0xff); if (temp < 0xdc00 || temp > 0xdfff) { // has to be a low surrogate here throw new EncodingExceptionHuge("UTF 16 BE encoding error: should never happen"); } val = ((val - 0xd800)<<10) + (temp - 0xdc00) + 0x10000; offset += 4; return val; } } public boolean skipChar(int ch)
public int getChar() throws EOFExceptionHuge, ParseExceptionHuge, EncodingExceptionHuge { int val = 0; if (offset >= endOffset) throw new EOFExceptionHuge("permature EOF reached, XML document incomplete"); int temp = (xb.byteAt(offset)&0xff) << 8 | (xb.byteAt(offset+1)&0xff); if ((temp < 0xd800) || (temp > 0xdfff)) { // not a high surrogate offset += 2; return temp; } else { if (temp<0xd800 || temp>0xdbff) throw new EncodingExceptionHuge("UTF 16 BE encoding error: should never happen"); val = temp; temp = (xb.byteAt(offset+2)&0xff) << 8 | (xb.byteAt(offset+3)&0xff); if (temp < 0xdc00 || temp > 0xdfff) { // has to be a low surrogate here throw new EncodingExceptionHuge("UTF 16 BE encoding error: should never happen"); } val = ((val - 0xd800)<<10) + (temp - 0xdc00) + 0x10000; offset += 4; return val; } } public boolean skipChar(int ch)
throw new EncodingExceptionHuge("Document is zero sized "); if (xb.byteAt(offset) == -2) { increment = 2; r = new UTF16BEReader(); } else throw new EncodingExceptionHuge("Unknown Character encoding: should be 0xff 0xfe"); } else if (xb.byteAt(offset) == -1) { increment = 2; r = new UTF16LEReader(); } else throw new EncodingExceptionHuge("Unknown Character encoding: not UTF-16LE"); } else if (xb.byteAt(offset) == -17){ if (xb.byteAt(offset+1) == -69 && xb.byteAt(offset+2)==-65){ throw new EncodingExceptionHuge("Unknown Character encoding: not UTF-8"); throw new EncodingExceptionHuge("Unknown Character encoding: not UTF-16BE");
throw new EncodingExceptionHuge("Document is zero sized "); if (xb.byteAt(offset) == -2) { increment = 2; r = new UTF16BEReader(); } else throw new EncodingExceptionHuge("Unknown Character encoding: should be 0xff 0xfe"); } else if (xb.byteAt(offset) == -1) { increment = 2; r = new UTF16LEReader(); } else throw new EncodingExceptionHuge("Unknown Character encoding: not UTF-16LE"); } else if (xb.byteAt(offset) == -17){ if (xb.byteAt(offset+1) == -69 && xb.byteAt(offset+2)==-65){ throw new EncodingExceptionHuge("Unknown Character encoding: not UTF-8"); throw new EncodingExceptionHuge("Unknown Character encoding: not UTF-16BE");
throw new EncodingExceptionHuge("Document is zero sized "); if (xb.byteAt(offset) == -2) { increment = 2; r = new UTF16BEReader(); } else throw new EncodingExceptionHuge("Unknown Character encoding: should be 0xff 0xfe"); } else if (xb.byteAt(offset) == -1) { increment = 2; r = new UTF16LEReader(); } else throw new EncodingExceptionHuge("Unknown Character encoding: not UTF-16LE"); } else if (xb.byteAt(offset) == -17){ if (xb.byteAt(offset+1) == -69 && xb.byteAt(offset+2)==-65){ throw new EncodingExceptionHuge("Unknown Character encoding: not UTF-8"); throw new EncodingExceptionHuge("Unknown Character encoding: not UTF-16BE");
&& encoding != FORMAT_UTF_16BE) { if (must_utf_8) throw new EncodingExceptionHuge( "Can't switch from UTF-8" + formatLineNumber()); || encoding == FORMAT_UTF_16BE) { if (!BOM_detected) throw new EncodingExceptionHuge( "BOM not detected for UTF-16" + formatLineNumber());
&& encoding != FORMAT_UTF_16BE) { if (must_utf_8) throw new EncodingExceptionHuge( "Can't switch from UTF-8" + formatLineNumber()); || encoding == FORMAT_UTF_16BE) { if (!BOM_detected) throw new EncodingExceptionHuge( "BOM not detected for UTF-16" + formatLineNumber());
&& encoding != FORMAT_UTF_16BE) { if (must_utf_8) throw new EncodingExceptionHuge( "Can't switch from UTF-8" + formatLineNumber()); || encoding == FORMAT_UTF_16BE) { if (!BOM_detected) throw new EncodingExceptionHuge( "BOM not detected for UTF-16" + formatLineNumber());
if (encoding <= FORMAT_UTF_16LE) { if (must_utf_8) throw new EncodingExceptionHuge( "Can't switch from UTF-8" + formatLineNumber());
if (encoding <= FORMAT_UTF_16LE) { if (must_utf_8) throw new EncodingExceptionHuge( "Can't switch from UTF-8" + formatLineNumber());