public static String escapeEncode(String s) {
		if (s == null) {
			return null;
		}

		String escapeChars = "%?|";
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (c < 32 || c > 126 || escapeChars.indexOf(c) >= 0) {
				appendHexEncoded(sb, c);
			}
			else {
				sb.append(c);
			}
		}
		return sb.toString();
	}
Returns a copy of the input string with FSRL problematic[1] characters escaped
as "%nn" sequences, where nn are hexdigits specifying the numeric ascii value
of that character.
<p>
Characters that need more than a byte to encode will result in multiple "%nn" values
that encode the necessary UTF8 codepoints.
<p>
[1] - non-ascii / unprintable / FSRL portion separation characters.

@param s string, or null.
@return string with problematic characters escaped as "%nn" sequences, or null
if parameter was null.
Ghidra/Features/Base/src/main/java/ghidra/formats/gfilesystem/FSUtilities.java