IMPORTANT - refactor MARC character set handling
[koha.git] / t / Charset.t
diff --git a/t/Charset.t b/t/Charset.t
new file mode 100755 (executable)
index 0000000..7de3414
--- /dev/null
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 6;
+BEGIN {
+    use_ok('C4::Charset');
+}
+
+my $octets = "abc";
+ok(IsStringUTF8ish($octets), "verify octets are valid UTF-8 (ASCII)");
+
+$octets = "flamb\c3\a9";
+ok(!utf8::is_utf8($octets), "verify that string does not have Perl UTF-8 flag on");
+ok(IsStringUTF8ish($octets), "verify octets are valid UTF-8 (LATIN SMALL LETTER E WITH ACUTE)");
+ok(!utf8::is_utf8($octets), "verify that IsStringUTF8ish does not magically turn Perl UTF-8 flag on");
+
+$octets = "a\xc2" . "c";
+ok(!IsStringUTF8ish($octets), "verify octets are not valid UTF-8");