| Store | Cart

[perl #123469] Bug in split function, with utf8 strings

From: Rostislav via RT <perl...@perl.org>
Sun, 21 Dec 2014 06:23:45 -0800
It seems it doesn't matter if there is a loop or not. The bug happens if the same split statement is executed several times.

[16:18] u...@debian7 ~/test/split $ cat split-func.pl
use strict;
use warnings;
use utf8;
use Data::Dumper;
binmode STDOUT, ':utf8';

sub my_split {
    return (split $_[0], $_[1])[0];
}

my $split_chr = 'รค';
my $good = "x${split_chr}y";
my $bad = 'xay';

print Dumper(my_split($split_chr, $good));
print Dumper(my_split($split_chr, $bad));
print Dumper(my_split($split_chr, $good));
[16:18] u...@debian7 ~/test/split $ perl5.20.1 split-func.pl
$VAR1 = 'x';
$VAR1 = 'xay';
$VAR1 = "x\x{e4}y"; # this should be the same as the first line


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=123469

Recent Messages in this Thread
Rostislav (via RT) Dec 21, 2014 11:07 am
Rostislav via RT Dec 21, 2014 11:16 am
Father Chrysostomos via RT Dec 21, 2014 07:29 pm
Rostislav via RT Dec 24, 2014 06:44 am
H.Merijn Brand Dec 24, 2014 08:14 am
Rostislav via RT Dec 24, 2014 10:14 am
demerphq Dec 24, 2014 01:48 pm
James E Keenan via RT Dec 21, 2014 01:48 pm
James E Keenan via RT Dec 21, 2014 02:13 pm
Rostislav via RT Dec 21, 2014 02:23 pm
Messages in this thread