Check Supported Encoding Types Using Perl

When working with ascii files, csv and other text format files you will often need to know the encoding that your system supports and the encoding of the file you are working with.

You can guess, or you can just ask the OS. Here is what my system supports natively

Sample Encoding List

  • ascii
  • ascii-ctrl
  • cp1252
  • iso-8859-1
  • null
  • utf-8-strict
  • utf8

Perl Script to Check Supported Encoding

Use Perl to Guess Encoding

There is a perl module already for this, and you must supply it with the proper choices to guess from.

Use Command Line to Guess Encodings

This is a binary on linux (and cygwin) called “file”. It will help determine file types. However, it’s not entirely accurate and like all guesses, it’s a “guess”.

The above script is just one tool in a series of tool kits needed to help troubleshoot encoding issues.

Leave a Reply

Your email address will not be published. Required fields are marked *