int getRestrictedStringLen(Program program, Address address, AbstractStringDataType dataType,
			int maxLength) {

		maxLength = getMaxStringLength(program, address, maxLength);

		MemoryBufferImpl memoryBuffer = new MemoryBufferImpl(program.getMemory(), address);

		StringDataInstance stringDataInstance =
			dataType.getStringDataInstance(memoryBuffer, dataType.getDefaultSettings(), -1);
		stringDataInstance.getStringDataTypeGuess();

		int detectedLength = stringDataInstance.getStringLength();
		if (detectedLength == -1) {
			return 0;
		}

		if (detectedLength > maxLength) {
			detectedLength = maxLength;
		}

		return detectedLength;
	}
Looks at bytes at given address and converts to format String

@param address Address of format String
@param pointer Pointer "type" of string
@return format String
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/ConstantPropagationContextEvaluator.java