@Internal
    String toEscapedString(final X500Principal principal) {
        final String principalValue = principal.getName(X500Principal.RFC2253);
        final StringBuilder sanitizedPrincipal = new StringBuilder(principalValue.length());
        for (final char c : principalValue.toCharArray()) {
            if (Character.isISOControl(c)) {
                sanitizedPrincipal.append(String.format("\\x%02x", (int) c));
            } else {
                sanitizedPrincipal.append(c);
            }
        }
        return sanitizedPrincipal.toString();
    }
Converts an X500Principal to a cleaned string by escaping control characters.
<p>
This method processes the RFC2253 format of the X500Principal and escapes
any ISO control characters to avoid issues in logging or other outputs.
Control characters are replaced with their escaped hexadecimal representation.
</p>

<p><strong>Note:</strong> For testing purposes, this method is package-private
to allow access within the same package. This allows tests to verify the correct
behavior of the escaping process.</p>

@param principal the X500Principal to escape
@return the escaped string representation of the X500Principal
httpclient5/src/main/java/org/apache/hc/client5/http/ssl/AbstractClientTlsStrategy.java