module CGI::EscapeExt - Documentation for Ruby 4.0
Description: Documentation for the CGI::EscapeExt module
Keywords: ruby,module,CGI::EscapeExt

🔍

No recent searches

# module CGI::EscapeExt

### Public Instance Methods

escape(string) → string
Source

    static VALUE
    cgiesc_escape(VALUE self, VALUE str)
    {
        StringValue(str);

        if (rb_enc_str_asciicompat_p(str)) {
            return optimized_escape(str, 1);
        }
        else {
            return rb_call_super(1, &str);
        }
    }

Returns URL-escaped string (`application/x-www-form-urlencoded`).

escapeHTML(string) → string
Source

    static VALUE
    cgiesc_escape_html(VALUE self, VALUE str)
    {
        StringValue(str);

        if (rb_enc_str_asciicompat_p(str)) {
            return optimized_escape_html(str);
        }
        else {
            return rb_call_super(1, &str);
        }
    }

Returns HTML-escaped string.

escapeURIComponent(string) → string
Source

    static VALUE
    cgiesc_escape_uri_component(VALUE self, VALUE str)
    {
        StringValue(str);

        if (rb_enc_str_asciicompat_p(str)) {
            return optimized_escape(str, 0);
        }
        else {
            return rb_call_super(1, &str);
        }
    }

Returns URL-escaped string following RFC 3986.

Also aliased as: escape_uri_component
escape_uri_component
Alias for: escapeURIComponent
unescape(string, encoding=@@accept_charset) → string
Source

    static VALUE
    cgiesc_unescape(int argc, VALUE *argv, VALUE self)
    {
        VALUE str = (rb_check_arity(argc, 1, 2), argv[0]);

        StringValue(str);

        if (rb_enc_str_asciicompat_p(str)) {
            VALUE enc = accept_charset(argc-1, argv+1, self);
            return optimized_unescape(str, enc, 1);
        }
        else {
            return rb_call_super(argc, argv);
        }
    }

Returns URL-unescaped string (`application/x-www-form-urlencoded`).

unescapeHTML(string) → string
Source

    static VALUE
    cgiesc_unescape_html(VALUE self, VALUE str)
    {
        StringValue(str);

        if (rb_enc_str_asciicompat_p(str)) {
            return optimized_unescape_html(str);
        }
        else {
            return rb_call_super(1, &str);
        }
    }

Returns HTML-unescaped string.

unescapeURIComponent(string, encoding=@@accept_charset) → string
Source

    static VALUE
    cgiesc_unescape_uri_component(int argc, VALUE *argv, VALUE self)
    {
        VALUE str = (rb_check_arity(argc, 1, 2), argv[0]);

        StringValue(str);

        if (rb_enc_str_asciicompat_p(str)) {
            VALUE enc = accept_charset(argc-1, argv+1, self);
            return optimized_unescape(str, enc, 0);
        }
        else {
            return rb_call_super(argc, argv);
        }
    }

Returns URL-unescaped string following RFC 3986.

Also aliased as: unescape_uri_component
unescape_uri_component
Alias for: unescapeURIComponent