public static String encodeId()

in doxia-core/src/main/java/org/apache/maven/doxia/util/DoxiaUtils.java [159:196]


    public static String encodeId(final String text) {
        if (text == null) {
            return null;
        }

        final String textt = text.trim();
        int length = textt.length();

        if (length == 0) {
            return null;
        }

        StringBuilder buffer = new StringBuilder(length);

        for (int i = 0; i < length; ++i) {
            char c = textt.charAt(i);

            if ((i == 0) && !(isAsciiLetter(c) || c == '_')) {
                buffer.append('a');
            }

            if (c == ' ') {
                buffer.append('_');
            } else if (isAsciiLetter(c) || isAsciiDigit(c) || (c == '-') || (c == '_') || (c == '.')) {
                buffer.append(c);
            } else {

                byte[] bytes = String.valueOf(c).getBytes(StandardCharsets.UTF_8);

                for (byte aByte : bytes) {
                    buffer.append('.');
                    buffer.append(String.format("%02X", aByte));
                }
            }
        }

        return buffer.toString();
    }