1use strict;
2use warnings;
3
4use Test::More tests => 12;
5
6use URI::Escape qw(%escapes uri_escape uri_escape_utf8 uri_unescape);
7
8is uri_escape("|abc�"), "%7Cabc%E5";
9
10is uri_escape("abc", "b-d"), "a%62%63";
11
12# New escapes in RFC 3986
13is uri_escape("~*'()"), "~%2A%27%28%29";
14is uri_escape("<\">"), "%3C%22%3E";
15
16is uri_escape(undef), undef;
17
18is uri_unescape("%7Cabc%e5"), "|abc�";
19
20is_deeply [uri_unescape("%40A%42", "CDE", "F%47H")], [qw(@AB CDE FGH)];
21
22is $escapes{"%"}, "%25";
23
24is uri_escape_utf8("|abc�"), "%7Cabc%C3%A5";
25
26skip "Perl 5.8.0 or higher required", 3 if $] < 5.008;
27
28ok !eval { print uri_escape("abc" . chr(300)); 1 };
29like $@, qr/^Can\'t escape \\x\{012C\}, try uri_escape_utf8\(\) instead/;
30
31is uri_escape_utf8(chr(0xFFF)), "%E0%BF%BF";
32