App-EscapeUtils
view release on metacpan or search on metacpan
lib/App/EscapeUtils.pm view on Meta::CPAN
summary => 'URI-unescape lines of input (in standard input or arguments)',
args => {
%arg_strings,
},
result => {
schema => 'str*',
stream => 1,
},
};
sub uri_unescape {
require URI::Escape;
my %args = @_;
my $strings = $args{strings};
my $cb = sub {
my $str = $strings->();
if (defined $str) {
return URI::Escape::uri_unescape($str);
} else {
return undef;
}
};
return [200, "OK", $cb];
}
$SPEC{js_escape} = {
v => 1.1,
summary => 'Encode lines of input (in standard input or arguments) '.
'as JSON strings',
args => {
%arg_strings,
},
result => {
schema => 'str*',
stream => 1,
},
};
sub js_escape {
require String::JS;
my %args = @_;
my $strings = $args{strings};
my $cb = sub {
my $str = $strings->();
if (defined $str) {
return String::JS::encode_js_string($str);
} else {
return undef;
}
};
return [200, "OK", $cb];
}
$SPEC{js_unescape} = {
v => 1.1,
summary => 'Interpret lines of input (in standard input or arguments) as '.
'JSON strings and return the decoded value',
args => {
%arg_strings,
},
result => {
schema => 'str*',
stream => 1,
},
};
sub js_unescape {
require String::JS;
my %args = @_;
my $strings = $args{strings};
my $cb = sub {
my $str = $strings->();
if (defined $str) {
return String::JS::decode_js_string($str);
} else {
return undef;
}
};
return [200, "OK", $cb];
}
$SPEC{backslash_escape} = {
v => 1.1,
summary => 'Escape lines of input using backslash octal sequence '.
'(or \\r, \\n, \\t)',
args => {
%arg_strings,
},
result => {
schema => 'str*',
stream => 1,
},
};
sub backslash_escape {
require String::Escape;
my %args = @_;
my $strings = $args{strings};
my $cb = sub {
my $str = $strings->();
if (defined $str) {
return String::Escape::backslash($str);
} else {
return undef;
}
};
return [200, "OK", $cb];
}
$SPEC{backslash_unescape} = {
v => 1.1,
summary => 'Restore backslash octal sequence (or \\r, \\n, \\t) to '.
'original characters in lines of input (in stdin or arguments)',
lib/App/EscapeUtils.pm view on Meta::CPAN
This function is not exported.
Arguments ('*' denotes required arguments):
=over 4
=item * B<strings>* => I<array[str]>
=back
Returns an enveloped result (an array).
First element (status) is an integer containing HTTP status code
(200 means OK, 4xx caller error, 5xx function error). Second element
(msg) is a string containing error message, or 'OK' if status is
200. Third element (payload) is optional, the actual result. Fourth
element (meta) is called result metadata and is optional, a hash
that contains extra information.
Return value: (str)
=head2 js_escape
Usage:
js_escape(%args) -> [status, msg, payload, meta]
Encode lines of input (in standard input or arguments) as JSON strings.
This function is not exported.
Arguments ('*' denotes required arguments):
=over 4
=item * B<strings>* => I<array[str]>
=back
Returns an enveloped result (an array).
First element (status) is an integer containing HTTP status code
(200 means OK, 4xx caller error, 5xx function error). Second element
(msg) is a string containing error message, or 'OK' if status is
200. Third element (payload) is optional, the actual result. Fourth
element (meta) is called result metadata and is optional, a hash
that contains extra information.
Return value: (str)
=head2 js_unescape
Usage:
js_unescape(%args) -> [status, msg, payload, meta]
Interpret lines of input (in standard input or arguments) as JSON strings and return the decoded value.
This function is not exported.
Arguments ('*' denotes required arguments):
=over 4
=item * B<strings>* => I<array[str]>
=back
Returns an enveloped result (an array).
First element (status) is an integer containing HTTP status code
(200 means OK, 4xx caller error, 5xx function error). Second element
(msg) is a string containing error message, or 'OK' if status is
200. Third element (payload) is optional, the actual result. Fourth
element (meta) is called result metadata and is optional, a hash
that contains extra information.
Return value: (str)
=head2 perl_dquote_escape
Usage:
perl_dquote_escape(%args) -> [status, msg, payload, meta]
Encode lines of input (in stdin or arguments) inside Perl double-quoted strings.
This function is not exported.
Arguments ('*' denotes required arguments):
=over 4
=item * B<strings>* => I<array[str]>
=back
Returns an enveloped result (an array).
First element (status) is an integer containing HTTP status code
(200 means OK, 4xx caller error, 5xx function error). Second element
(msg) is a string containing error message, or 'OK' if status is
200. Third element (payload) is optional, the actual result. Fourth
element (meta) is called result metadata and is optional, a hash
that contains extra information.
Return value: (str)
=head2 perl_squote_escape
Usage:
perl_squote_escape(%args) -> [status, msg, payload, meta]
( run in 1.847 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )