+sub uri_encode {
+ my ($str) = @_;
+
+ $str = Encode::encode('utf-8-strict', $str);
+ $str =~ s/([^a-zA-Z0-9_.:-])/sprintf("%%%02x", ord($1))/ge;
+
+ return $str;
+}
+
+sub uri_decode {
+ my $str = $_[0] // '';
+
+ $str =~ tr/+/ /;
+ $str =~ s/\\$//;
+
+ $str =~ s/%([0-9a-fA-Z]{2})/pack("C",hex($1))/eg;
+ $str = Encode::decode('utf-8-strict', $str);
+
+ return $str;
+}
+