code: public int putUTF8(int pos, String s) {
  		ByteBuffer minibb = null;
  		
  		CharsetEncoder enc = getUTF8Encoder();
  		CharBuffer in = CharBuffer.wrap(s);
  		
  		int pos2 = pos;
  		ByteBuffer bb = getBuffer(pos2);
  		int index = pos2 % _bufferSize;
  		bb.position(index);
  		
  		while (in.remaining() > 0) {
  			CoderResult res = enc.encode(in, bb, true);
  			
  			//flush minibb first
  			if (bb == minibb) {
  				bb.flip();
  				while (bb.remaining() > 0) {
  					putByte(pos2, bb.get());
  					++pos2;
  				}
  			} else {
  				pos2 += bb.position() - index;
  			}
  			
  			if (res.isOverflow()) {
  				if (bb.remaining() > 0) {
  					//exceeded buffer boundaries; write to a small temporary buffer
  					if (minibb == null) {
  						minibb = ByteBuffer.allocate(4);
  					}
  					minibb.clear();
  					bb = minibb;
  					index = 0;
  				} else {
  					bb = getBuffer(pos2);
  					index = pos2 % _bufferSize;
  					bb.position(index);
  				}
  			} else if (res.isError()) {
  				try {
  					res.throwException();
  				} catch (CharacterCodingException e) {
  					throw new RuntimeException("Could not encode string", e);
  				}
  			}
  		}
  		
  		adaptSize(pos2);
  		return pos2 - pos;
  	}
docs: Puts the given string as UTF-8 into the buffer at the
  given position. This method does not increase the write position.
  @param pos the position where to put the string
  @param s the string to put
  @return the number of UTF-8 bytes put