diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-05-07 05:39:55 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-05-07 05:39:55 +0000 |
commit | 7f66633bd788f56bb4e77473ec86f45e8cc0614b (patch) | |
tree | 9acfaccce4b612cbcc1a6848ccafa4c1f7acb1dc /t/op/substr.t | |
parent | 277ddfaf09c11f4f38a1c6f63c004bfe4d066e3d (diff) | |
download | perl-7f66633bd788f56bb4e77473ec86f45e8cc0614b.tar.gz |
substr() does not preserve utf8-ness (from Stefan Eissing
<Eissing@medicaldataservice.de>); added tests
p4raw-id: //depot/perl@6084
Diffstat (limited to 't/op/substr.t')
-rwxr-xr-x | t/op/substr.t | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/t/op/substr.t b/t/op/substr.t index 5764e67e7a..6180acc402 100755 --- a/t/op/substr.t +++ b/t/op/substr.t @@ -1,5 +1,5 @@ -print "1..125\n"; +print "1..130\n"; #P = start of string Q = start of substr R = end of substr S = end of string @@ -268,3 +268,15 @@ ok 123, $@ && $@ =~ /Can't modify substr/ && $a eq "foo"; $a = "abcdefgh"; ok 124, sub { shift }->(substr($a, 0, 4, "xxxx")) eq 'abcd'; ok 125, $a eq 'xxxxefgh'; + +# utf8 sanity +{ + my $x = substr("a\x{263a}b",0); + ok 126, length($x) eq 3; + $x = substr($x,1,1); + ok 127, $x eq "\x{263a}"; + ok 128, length($x) eq 1; + substr($x,0,1) = "abcd"; + ok 129, $x eq "abcd"; + ok 130, length($x) eq 4; +} |