String (@NotNull String string) { StringBuilder result = new StringBuilder(); for (char c : string.toCharArray()) { if (isNonPrintable(c)) { result.append("\\x"); result.append(charToHEX(c)); } else { result.append(c); } } return result.toString(); }