Term::Encoding is a simple module to detect an encoding the current terminal expects, in various ways.