public default byte[] encodeCharacterValue(Object value, MemBuffer buf, Settings settings)
			throws DataTypeEncodeException {
		char[] normalizedValue;
		if (value instanceof Character) {
			normalizedValue = new char[] { (Character) value };
		}
		else if (value instanceof char[]) {
			normalizedValue = (char[]) value;
			if (normalizedValue.length > 2) {
				throw new DataTypeEncodeException("char[] must represent a single code point",
					value, this);
			}
		}
		else {
			throw new DataTypeEncodeException(
				"Requires Character or char[] with a single code point", value, this);
		}
		StringDataInstance sdi = new StringDataInstance(this, settings, buf, getLength());
		try {
			return sdi.encodeReplacementFromCharValue(normalizedValue);
		}
		catch (Throwable e) {
			throw new DataTypeEncodeException(value, this, e);
		}
	}
Utility for character data types to encode a value.

@param value the character value to encode.
@param buf a buffer representing the eventual destination of the bytes.
@param settings the settings to use.
@return the encoded value
@throws DataTypeEncodeException if the value cannot be encoded
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/DataTypeWithCharset.java