summaryrefslogtreecommitdiff
path: root/t/uni
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-04-29 13:43:26 +0000
committerNicholas Clark <nick@ccl4.org>2006-04-29 13:43:26 +0000
commitec9af7d430b6660eff7240fa20757fa5feb233a8 (patch)
tree73503877ffc9eeabc96eb111fde7fab6b962fc92 /t/uni
parentca0270c4db0273594a19a3d140c7330546a185fe (diff)
downloadperl-ec9af7d430b6660eff7240fa20757fa5feb233a8.tar.gz
lc plus an 8 bit locale could mangle UTF-8 values returned by
overloaded stringification. p4raw-id: //depot/perl@28011
Diffstat (limited to 't/uni')
-rw-r--r--t/uni/overload.t30
1 files changed, 27 insertions, 3 deletions
diff --git a/t/uni/overload.t b/t/uni/overload.t
index 9338f75816..3ecfafbe41 100644
--- a/t/uni/overload.t
+++ b/t/uni/overload.t
@@ -7,9 +7,9 @@ BEGIN {
}
}
-use Test::More tests => 8;
+use Test::More tests => 12;
-package UTF8Field;
+package UTF8Toggle;
use strict;
use overload '""' => 'stringify';
@@ -36,9 +36,33 @@ package main;
foreach my $t ("ASCII", "B\366se") {
my $length = length $t;
- my $u = UTF8Field->new($t);
+ my $u = UTF8Toggle->new($t);
is (length $u, $length, "length of '$t'");
is (length $u, $length, "length of '$t'");
is (length $u, $length, "length of '$t'");
is (length $u, $length, "length of '$t'");
}
+
+my $have_setlocale = 0;
+eval {
+ require POSIX;
+ import POSIX ':locale_h';
+ $have_setlocale++;
+};
+
+SKIP: {
+ if (!$have_setlocale) {
+ skip "No setlocale", 4;
+ } elsif (!setlocale(&POSIX::LC_ALL, "en_GB.ISO8859-1")) {
+ skip "Could not setlocale to en_GB.ISO8859-1", 4;
+ } else {
+ use locale;
+ my $u = UTF8Toggle->new("\311");
+ my $lc = lc $u;
+ is (length $lc, 1);
+ is ($lc, "\351", "E accute -> e accute");
+ $lc = lc $u;
+ is (length $lc, 1);
+ is ($lc, "\351", "E accute -> e accute");
+ }
+}