Also some of the comments in your tests look suspect:
But $a isn't upgraded anywhere.is( $a, $b, '$a eq $b after utf8 upgrade of $a' );
You're testing $b, not $x.ok( Encode::is_utf8($b), '$x is utf-8' );
_utf8_off does not alter the encoding, it just switches the utf-8 flag, so $a and $b should not be the same, since $a is latin-1 and $b is the same character in utf-8 but marked as latin-1.Encode::_utf8_off( $b ); # ... is( $a, $b, '$a and $b are byte same' );
That last test is the only one that fails on my machine with perl 5.8.8, and as far as I can see, it's the only one that *should* fail.
A correct way to ensure a string really is utf-8 encoded (assuming it's already flagged correctly as either utf-8 or latin) is to use utf8::upgrade()
See also A UTF8 round trip with MySQL - but read the whole thread!
In reply to Re: Why does perl not mark variable as utf-8?
by Joost
in thread Why does perl not mark variable as utf-8?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |