public static String jsEncode(String str) {
        if (null == str) {
            return null;
        }

        char[] cs = str.toCharArray();
        StringBuilder sBuilder = new StringBuilder(str.length());

        for (int i = 0; i < cs.length; ++i) {
            int c = cs[i] & 0xFFFF;

            if (((c >= '0') && (c <= '9')) || (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')))) {
                sBuilder.append(cs[i]);
            } else {
                sBuilder.append('%');

                if (c > 255) {
                    sBuilder.append('u');
                }

                sBuilder.append(Integer.toHexString(c));
            }
        }

        return sBuilder.toString();
    }
Encoding according to the escape method in javascript

@return Encoded string
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/master/web/common/BaseResult.java