in reply to Re: cut of first char of a string
in thread cut of first char of a string
This means that the regexp and chop methods will work on full "characters", but substr operates on "bytes".
AFAIK unless the use bytes pragma is in effect substr operates on characters, not on bytes. Maybe the behaviour you describe is true pre 5.8.x but it isnt true in 5.8:
D:\Development>perl5.8.5 -le "my $str='ba'.pack('U',0x0370).'!'; print +f qq'$_ : %d\n', ord(substr($str,$_,1)) for 0..length($str)-1" 0 : 98 1 : 97 2 : 880 3 : 33 D:\Development>perl5.8.5 -Mbytes -le "my $str='ba'.pack('U',0x0370).'! +'; printf qq'$_ : %d\n', ord(substr($str,$_,1)) for 0..length($str)-1 +" 0 : 98 1 : 97 2 : 205 3 : 176 4 : 33
|
|---|