def get_encoding_name(self, encoding):
        """Given an encoding provided by the user, will return a
        canonical encoding name; and also validate that the encoding
        is supported.

        TODO: Support encoding aliases: pc437 instead of cp437.
        """
        encoding = CodePages.get_encoding_name(encoding)
        if encoding not in self.codepages:
            raise ValueError((
                'Encoding "{}" cannot be used for the current profile. '
                'Valid encodings are: {}'
                ).format(encoding, ','.join(self.codepages.keys())))
        return encoding