NAME
HTTP::AcceptCharset - Parse the HTTP header 'Accept-Charset'
VERSION
version 0.04
SYNOPSIS
use HTTP::AcceptCharset;
my $header = 'utf-8, iso-8859-1;q=0.5';
my $charset_header = HTTP::AcceptCharset->new( $header );
# returns utf-8
my $use_charset = $charset_header->match( qw/iso-8859-1 utf-8/ );
ATTRIBUTES
string
The header string as passed to new
.
values
The given charset in the prioritized order.
Header | Values
--------------------------+----------------------------
utf-8, iso-8859-1;q=0.5 | utf-8, iso-8859-1
iso-8859-1;q=0.5, utf-8 | utf-8, iso-8859-1
utf-8 | utf-8
utf-8, * | utf-8, *
utf-8;q=0.2, utf-16;q=0.5 | utf-16, utf-8
METHODS
new
my $header = 'utf-8, iso-8859-1;q=0.5';
my $charset_header = HTTP::AcceptCharset->new( $header );
match
# header: 'utf-8, iso-8859-1;q=0.5';
my $charset = $charset_header->match('utf-8'); # utf-8
my $charset = $charset_header->match('iso-8859-1'); # iso-8859-1
my $charset = $charset_header->match('iso-8859-1', 'utf-8'); # utf-8
my $charset = $charset_header->match(); # empty string
my $charset = $charset_header->match(undef); # empty string
my $charset = $charset_header->match('utf-16'); # empty string
Development
The distribution is contained in a Git repository, so simply clone the repository
$ git clone git://github.com/reneeb/HTTP-AcceptCharset.git
and change into the newly-created directory.
$ cd HTTP-AcceptCharset
The project uses Dist::Zilla
to
build the distribution, hence this will need to be installed before
continuing:
$ cpanm Dist::Zilla
To install the required prequisite packages, run the following set of commands:
$ dzil authordeps --missing | cpanm
$ dzil listdeps --author --missing | cpanm
The distribution can be tested like so:
$ dzil test
To run the full set of tests (including author and release-process tests),
add the --author
and --release
options:
$ dzil test --author --release
AUTHOR
Renee Baecker reneeb@cpan.org
COPYRIGHT AND LICENSE
This software is Copyright (c) 2018 by Renee Baecker.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)