private static void generateHexEscape(StringBuilder buffer, int value) {
		String res = Integer.toHexString(value);
		int pad = res.length();
		if (pad > 4) {
			pad = 8;
		}
		else if (pad > 2) {
			pad = 4;
		}
		else {
			pad = 2;
		}
		pad = pad - res.length();
		buffer.append("'\\x");
		for (int i = 0; i < pad; ++i) {
			buffer.append('0');
		}
		buffer.append(res.toLowerCase());
		buffer.append('\'');
	}
Convert a selected constant in the decompiler window to a character representation.
Ghidra/Features/Decompiler/src/main/java/ghidra/app/plugin/core/decompile/actions/ConvertCharAction.java