Aion-Format

 view release on metacpan or  search on metacpan

t/aion/format/url.pm  view on Meta::CPAN

use common::sense; use open qw/:std :utf8/;  use Carp qw//; use Cwd qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//;  use Test::More 0.98;  use String::Diff q...
# 
# use common::sense;
# 
# use List::Util qw//;
# use Encode qw//;
# 
# use Exporter qw/import/;
# our @EXPORT = our @EXPORT_OK = grep {
# 	ref \$Aion::Format::Url::{$_} eq "GLOB"
# 		&& *{$Aion::Format::Url::{$_}}{CODE} && !/^(_|(NaN|import)\z)/n
# } keys %Aion::Format::Url::;
# 
# 
# #@category escape url
# 
# use constant UNSAFE_RFC3986 => qr/[^A-Za-z0-9\-\._~]/;
# 
# # Эскейпит значение
# sub to_url_param(;$) {
# 	my ($param) = @_ == 0? $_: @_;
# 	use bytes;
# 	$param =~ s/${\ UNSAFE_RFC3986}/$& eq " "? "+": sprintf "%%%02X", ord $&/ge;
# 	$param
# }
# 
# # Преобразует в формат url-параметров
# sub to_url_params(;$) {
# 	my ($param) = @_ == 0? $_: @_;
# 
# 	my @R;
# 	my @S = [$param];
# 	while(@S) {
# 		my $u = pop @S;
# 		my ($x, $key) = @$u;
# 		
# 		if(ref $x eq "HASH") {
# 			push @S, defined($key)
# 				? (map [$x->{$_}, "$key\[${\to_url_param}]"], sort keys %$x)
# 				: (map [$x->{$_}, to_url_param], sort keys %$x)
# 			;
# 		}
# 		elsif(ref $x eq "ARRAY") {
# 			push @S, map [$_, "$key\[]"], @$x;
# 		}
# 		elsif(!defined $x) {}
# 		elsif($x eq 1) { unshift @R, $key }
# 		else {
# 			unshift @R, join "=", $key, to_url_param $x;
# 		}
# 	}
# 	
# 	join "&", @R
# }
# 
# # Определяет кодировку. В koi8-r и в cp1251 большие и малые буквы как бы поменялись местами, поэтому у правильной кодировки вес будет больше
# sub _bohemy {
# 	my ($s) = @_;
# 	my $c = 0;
# 	while($s =~ /[а-яё]+/gi) {
# 		my $x = $&;



( run in 0.528 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )