Moved header & footer logic into the templates.
[catagits/Gitalist.git] / lib / Gitalist / Util.pm
CommitLineData
86382b95 1package Gitalist::Util;
2
3use Sub::Exporter -setup => {
4 exports => ['to_utf8']
5};
6
7=pod
8
9=head1 NAME
10
11Gitalist::Util - Your usual catch all utility function package.
12
13=cut
14
15# decode sequences of octets in utf8 into Perl's internal form,
16# which is utf-8 with utf8 flag set if needed. gitweb writes out
17# in utf-8 thanks to "binmode STDOUT, ':utf8'" at beginning
18sub to_utf8 {
19 my $str = shift;
20 if (utf8::valid($str)) {
21 utf8::decode($str);
22 return $str;
23 } else {
24 return decode($fallback_encoding, $str, Encode::FB_DEFAULT);
25 }
26}
27
281;