public ByteBuffer parse(CharBuffer in)
			throws StringParseException, MalformedInputException, UnmappableCharacterException {
		int bufSize = in.remaining() * 2; // We don't know the charset, yet.
		while (true) {
			ByteBuffer out = ByteBuffer.allocate(bufSize)
					.order(endian == Endian.BIG ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
			int pos = in.position();
			try {
				parse(out, in);
				finish(out);
				out.flip();
				return out;
			}
			catch (BufferOverflowException e) {
				bufSize <<= 1;
				in.position(pos);
				reset();
			}
		}
	}
Parse and encode a complete string or character representation

@param in the buffer containing the representation
@return a buffer containing the encoded string or character
@throws StringParseException if the representation could not be parsed
@throws MalformedInputException if a character sequence in the representation is not valid
@throws UnmappableCharacterException if a character cannot be encoded
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/StringRenderParser.java