#!/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"; #### 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 ---------------------------------------------