public static String toQuotedString(byte[] bytes, int charSize) {
		if (charSize <= 1) {
			return toQuotedString(bytes);
		}
		else if (charSize > 4) {
			throw new IllegalArgumentException("unsupported charSize: " + charSize);
		}
		int shortage = bytes.length % charSize;
		if (shortage != 0) {
			byte[] paddedBytes = new byte[bytes.length + shortage];
			System.arraycopy(bytes, 0, paddedBytes, 0, bytes.length);
			bytes = paddedBytes;
		}
		StringBuilder builder = new StringBuilder();
		for (int i = 0; i < bytes.length; i += charSize) {
			int val = 0;
			for (int n = 0; n < charSize; n++) {
				val = (val << 8) + (bytes[i + n] & 0xff);
			}
			appendCharConvertedToEscapeSequence(val, charSize, builder);
		}
		String str = builder.toString();
		if (bytes.length <= charSize) {
			str = str.replace("'", "\\'");
			return "'" + str + "'";
		}
		str = str.replace("\"", "\\\"");
		return "\"" + str + "\"";
	}
Generate a quoted string from US-ASCII characters, where each character is charSize bytes.
<p>
Special characters and non-printable characters will be escaped using C character escape
conventions (e.g., \t, \n, \\uHHHH, etc.).
<p>
The result string will be single quoted (ie. "'") if the input byte array is 1 character long
(ie. charSize), otherwise the result will be double-quoted ('"').

@param bytes array of bytes
@param charSize number of bytes per character (1, 2, 4).
@return escaped string for display use
Ghidra/Framework/Generic/src/main/java/ghidra/util/StringUtilities.java