Thanks for the response. Here's a more succinct example that demonstrates this issue in a different way.
#!/usr/bin/perl + use strict; use warnings; use Encode qw( ); my $orig = "\xE8\xAB\x86\x0A"; utf8::encode( my $enc_once = $orig ); utf8::decode( $enc_once ); print('length after first decode= ', length($enc_once), "\n"); utf8::decode( $enc_once ); print('length after second decode= ', length($enc_once), "\n"); # do it again but don't check the intermediate length utf8::encode( $enc_once = $orig ); utf8::decode( $enc_once ); utf8::decode( $enc_once ); print('length after second decode= ', length($enc_once), "\n");
Here's the output:
length after first decode= 4 length after second decode= 4 length after second decode= 2
Apparently checking the length before decoding again changes the result of calling length again, which I don't understand.
In reply to Re^2: utf8::decode vs. Encode::decode with regard to the length function
by Anonymous Monk
in thread utf8::decode vs. Encode::decode with regard to the length function
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |