public void createEncodedString(String address, String string, Charset encoding,
			boolean nullTerminate) throws Exception {
		byte[] bytes = string.getBytes(encoding);

		if (encoding == StandardCharsets.US_ASCII || encoding == StandardCharsets.UTF_8) {
			if (nullTerminate) {
				bytes = Arrays.copyOf(bytes, bytes.length + 1);
			}
			setBytes(address, bytes);
			applyDataType(address, new StringDataType(), 1);
		}
		else if (encoding == StandardCharsets.UTF_16BE || encoding == StandardCharsets.UTF_16LE) {
			if (nullTerminate) {
				bytes = Arrays.copyOf(bytes, bytes.length + 2);
				setBytes(address, bytes);
				applyDataType(address, new TerminatedUnicodeDataType(), 1);
			}
			else {
				setBytes(address, bytes);
			}
		}
		else {
			setBytes(address, bytes);
		}
	}
Creates a sting data type instance at the specified address, repeated {@code N} times.

@param addressString address.
@param dt {@link AbstractStringDataType} string type to place at address.
@param n repeat count.
Ghidra/Features/Base/src/main/java/ghidra/program/database/ProgramBuilder.java