Revision f2b3e089
Von Jan Büren vor mehr als 6 Jahren hinzugefügt
SL/DATEV/CSV.pm | ||
---|---|---|
3 | 3 |
use strict; |
4 | 4 |
use Carp; |
5 | 5 |
use DateTime; |
6 |
use Encode qw(decode);
|
|
6 |
use Encode qw(encode);
|
|
7 | 7 |
use Scalar::Util qw(looks_like_number); |
8 | 8 |
|
9 | 9 |
use SL::DB::Datev; |
... | ... | |
260 | 260 |
my ($test) = @_; |
261 | 261 |
return undef unless $test; |
262 | 262 |
if (eval { |
263 |
decode('Windows-1252', $test, Encode::FB_CROAK|Encode::LEAVE_SRC);
|
|
263 |
encode('Windows-1252', $test, Encode::FB_CROAK|Encode::LEAVE_SRC);
|
|
264 | 264 |
1 |
265 | 265 |
}) { |
266 | 266 |
return 1; |
t/datev/encoding.t | ||
---|---|---|
1 |
use strict; |
|
2 |
use Test::More; |
|
3 |
|
|
4 |
use lib 't'; |
|
5 |
|
|
6 |
use_ok 'Support::TestSetup'; |
|
7 |
use SL::DATEV::CSV qw(check_text); |
|
8 |
use Support::TestSetup; |
|
9 |
|
|
10 |
use utf8; |
|
11 |
Support::TestSetup::login(); |
|
12 |
|
|
13 |
my $ascii = 'foobar 443334 hallo'; |
|
14 |
my $german = 'üßäüö €'; |
|
15 |
my $croatia = 'Kulašić hat viele €'; |
|
16 |
my $armenian = 'Հայերեն ֏'; |
|
17 |
|
|
18 |
is 1, SL::DATEV::CSV::check_encoding($ascii), 'ASCII Encoding'; |
|
19 |
is 1, SL::DATEV::CSV::check_encoding($german), 'German umlaut, euro and ligatur Encoding'; |
|
20 |
is undef, SL::DATEV::CSV::check_encoding($croatia), 'croatia with euro Encoding'; |
|
21 |
is undef, SL::DATEV::CSV::check_encoding($armenian), 'armenian Encoding'; |
|
22 |
|
|
23 |
done_testing; |
Auch abrufbar als: Unified diff
DATEV/CSV check_encoding, sollte wirklich das encoding checken
Entsprechend vier Testfälle für die Routine gesetzt und
Hintergründe in #348 dokumentiert.