title: How can I guess the encoding of a string in Perl?
body: <p>I have a Unicode string and don't know what its encoding is. When this string is read by a Perl program, is there a default encoding that Perl will use? If so, how can I find out what it is?</p>
  
  <p>I am trying to get rid of non-ASCII characters from the input. I found this on some forum that will do it:</p>
  
  <pre><code>my $line = encode('ascii', normalize('KD', $myutf), sub {$_[0] = ''});
  </code></pre>
  
  <p>How will the above work when no input encoding is specified? Should it be specified like the following?</p>
  
  <pre><code>my $line = encode('ascii', normalize('KD', decode($myutf, 'input-encoding'), sub {$_[0] = ''});
  </code></pre>