diff options
author | Yorhel <git@yorhel.nl> | 2010-12-09 16:54:56 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2010-12-09 16:54:56 +0100 |
commit | 4f91b0b1229e3037f2937acf3e4ec994f33de4f4 (patch) | |
tree | b71940eb74dd979bbb4dff679d921c88db6c25e3 /lib/VNDBUtil.pm | |
parent | 72dd32c56b944d207dc70cbe4fc37f8298bd4366 (diff) |
Write VNDBUtil::uri_escape() and removed dependency on URI::Escape
Its functionality is too simpel to require it as a special dependency,
seriously.
Diffstat (limited to 'lib/VNDBUtil.pm')
-rw-r--r-- | lib/VNDBUtil.pm | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/VNDBUtil.pm b/lib/VNDBUtil.pm index b0213d07..36038d47 100644 --- a/lib/VNDBUtil.pm +++ b/lib/VNDBUtil.pm @@ -5,9 +5,10 @@ package VNDBUtil; use strict; use warnings; use Exporter 'import'; +use Encode 'encode_utf8'; use Unicode::Normalize 'NFKD'; -our @EXPORT = qw|shorten bb2html gtintype normalize normalize_titles normalize_query imgsize|; +our @EXPORT = qw|shorten bb2html gtintype normalize normalize_titles normalize_query imgsize uri_escape|; sub shorten { @@ -240,5 +241,14 @@ sub imgsize { } +# Same as URI::Escape::uri_escape_utf8(), only simpler and doesn't add extra +# dependencies +sub uri_escape { + local $_ = encode_utf8 shift; + s/([^A-Za-z0-9._~-])/sprintf '%%%02X', ord $1/eg; + return $_; +} + + 1; |