/** * @return the character set id for the conversion */ public String getCharacterEncoding() { return converter.getCharacterEncoding(); }
private int acceptInput() throws IOException { converter.swizzInputBuffer(); byte[] inbuffer = converter.getInputBuffer(); int inbufferlimit = converter.getInputBufferLimit(); int bytesread = inputstream.read (inbuffer, inbufferlimit, inbuffer.length - inbufferlimit); if (bytesread != -1) { converter.increaseInputBufferLimit(bytesread); } // System.out.println("acceptInput read "+ bytesread+" bytes"); return bytesread; }
public void handleEncodingError(String errortype) { for (int i = 0; i < input_sequence_length; ++ i) { // remember to mask for sign-extension widening outputChar[i] = (char)(0xdc00 + (inbuffer[inbufferpos + i] & 0xff)); } // Kuhn actually recommends output sequence of 1 byte here, but this is // inconsistent with his other advice about lossless error encoding output_sequence_length = input_sequence_length; super.handleEncodingError(errortype); }
private int convertInternal() throws IOException { int outbufferstart = converter.getOutputBufferPos(); int bytesread = 0; int stop_reason = converter.convert(); if (converter.missing_bytes() > 0) { converter.handleEncodingError("Premature end of input stream during " + converter.getCharacterEncoding() + " sequence"); int outputchars = converter.getOutputBufferPos() - outbufferstart;
public void setInputStream(InputStream inputstream, String encoding, int buffersize) { if (converter == null || converter.getCharacterEncoding() != encoding) { if ("UTF-8".equals(encoding)) { converter = new ByteToCharUTF8(); } } converter.blastState(); converter.ensureInputBuffer(buffersize); this.inputstream = inputstream; }
public void close() throws IOException { if (inputstream != null) { inputstream.close(); } converter.blastState(); }