The manakai project


URL percent encoding and application/x-www-form-urlencoded


  use Web::URL::Encoding;
  warn percent_encode_c $text;
  warn serialize_form_urlencoded {
    $name => $value,
    $name => [$value1, $value2],


The Web::URL::Encoding module exports a function for the percent-encoding and the application/x-www-form-urlencoded encoding.


The following functions are exported by default:

$bytes = percent_encode_c $text

Percent-encode the string, encoded in UTF-8. Anything other than [A-Za-z0-9_.-] are percent-encoded.

$text = percent_decode_c $bytes

Percent-decode the bytes and then decode as a UTF-8 string.

$bytes = percent_decode_b $bytes

Percent-decode the bytes and return the result bytes.

$bytes = oauth1_percent_encode_c $text

Percent-encode the string, encoded in UTF-8, for OAuth 1.0.

$bytes = oauth1_percent_encode_b $text

Percent-encode the bytes, for OAuth 1.0.

$bytes = serialize_form_urlencoded $params

Serialize a hash reference as an application/x-www-form-urlencoded bytes.

The argument must be a hash reference where keys are names of the encoded form data set and values are corresponding values.

If the value is undef, that key/value pair is ignored. If the value is an array reference, the items in the array are used as values of name/value pairs with same name. The order is preserved. The array can be empty.

The values are encoded in UTF-8.


URL Standard <>.

RFC 5849, The OAuth 1.0 Protocol <>.

When a text is encoded in UTF-8, "UTF-8 encode" steps of the Encoding Standard MUST be used.

Encoding Standard <>.


SuikaWiki:percent-encoding <>.


The module partially derived from URL::PercentEncode <> and Web::UserAgent::Functions and Web::UserAgent::OAuth from <>.


Wakaba <>.


Copyright 2009-2013 Hatena <>.

Copyright 2014-2016 Wakaba <>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.