// encode all the characters that fit into the output byte buffer
boolean done = false;
byte[] bytes = new byte[width];
while (!done) {
int begin = allChars.position();
allChars.mark();
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
CoderResult coderResult = encoder.encode(allChars, byteBuffer, false);
int end = allChars.position();
int length = end - begin;
if (length == 0) {