Subject: | Fatal warning for UTF-16 surrogates on old perls |
On perls 5.8.8 through 5.12.x, regex matches against UTF-16 surrogate characters emits a fatal "Malformed UTF-8 character" warning if warnings are enabled. ExtUtils::MakeMaker prior to 6.78 runs the test suite with -w, causing the installation to fail.
The attached patch disables utf8 warnings while doing the regex substitution and converting the character number to a character in the test.
Subject: | unidecode-no-utf8-warnings.patch |
--- a/lib/Text/Unidecode.pm 2014-06-30 08:54:22.000000000 +0100
+++ b/lib/Text/Unidecode.pm 2014-07-24 11:36:21.555068805 +0100
@@ -44,6 +44,9 @@
foreach my $n (@_) {
next unless defined $n;
+ # Shut up potentially fatal warnings about UTF-16 surrogate
+ # characters when running under perl -w
+ no warnings 'utf8';
$n =~ s~([^\x00-\x7f])~${$Char[ord($1)>>8]||t($1)}[ord($1)&255]~egs;
}
# Replace character 0xABCD with $Char[0xAB][0xCD], loading
--- a/t/02000_uniform_table_sizes.t 2014-06-18 01:42:57.000000000 +0100
+++ b/t/02000_uniform_table_sizes.t 2014-07-24 11:35:36.034984852 +0100
@@ -24,7 +24,8 @@
Bank:
foreach my $banknum ( @Bank_Numbers ) {
my $charnum = $banknum << 8;
- my $char = chr( $charnum );
+ # Shut up warnings about UTF-16 surrogate characters
+ my $char = do { no warnings 'utf8'; chr( $charnum ) };
print "# About to test banknum $banknum via charnum $charnum\:\n";