jbert has asked for the wisdom of the Perl Monks concerning the following question:
to print "isn't tagged as a unicode string".#!/usr/bin/perl use warnings; use strict; use Encode;; my $octets = "abcd"; my $ustr = Encode::decode('utf8', $octets); print Encode::is_utf8($ustr) ? "is" : "isn't", " tagged as a unicode string\n";
But I don't, I get "is tagged as a unicode string" as the output.
What I believe to be the relevant section of the docs is:
I'm sure I've seen this not-tagging-ASCII behaviour in older versions of Encode (I think 2.01), too.Here is how Encode takes care of the utf8 flag. * When you encode, the resulting utf8 flag is always off. * When you decode, the resulting utf8 flag is on unless you can unambiguously represent data. Here is the definition of dis-ambiguity. After $utf8 = decode('foo', $octet);, When $octet is... The utf8 flag in $utf8 is --------------------------------------------- In ASCII only (or EBCDIC only) OFF In ISO-8859-1 ON In any other Encoding ON ---------------------------------------------
I'm running perl 5.8.8, Encode 2.12.
Can anyone else confirm that this is a bug, or have I got my encodings and flags in a twist.
|
|---|