| 1 | # $Id$ | ||||||||||
| 2 | # | ||||||||||
| 3 | # Copyright (c) 2007 Daisuke Maki daisuke@endeworks.jp> | ||||||||||
| 4 | # All rights reserved. | ||||||||||
| 5 | |||||||||||
| 6 | package Data::Decode::Util; | ||||||||||
| 7 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 4 | ▶ | use Encode (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 4 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 4 | our @EXPORT_OK = qw(try_decode pick_encoding); | |||||||||
| 12 | |||||||||||
| 13 | sub try_decode | ||||||||||
| 14 | 0 | ▶ | { | ||||||||
|
Subroutine
try_decode: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 15 | 0 | my ($encoding, $data) = @_; | |||||||||
| 16 | 0 | ▶ | return () unless $encoding; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 0 | my $decoded = eval { Encode::decode($encoding, $data, Encode::FB_CROAK()) }; | |||||||||
| 18 | 0 | return $decoded; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | sub pick_encoding | ||||||||||
| 22 | 0 | ▶ | { | ||||||||
|
Subroutine
pick_encoding: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 23 | 0 | for my $e (@_) { | |||||||||
| 24 | 0 | ▶ | next unless defined $e; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 0 | ▶ | next unless Encode::find_encoding($e); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | return $e; | |||||||||
| 27 | } | ||||||||||
| 28 | 0 | return (); | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 4 | 1; | |||||||||
| 32 | |||||||||||
| 33 | __END__ | ||||||||||