def _get_normal_name(orig_enc):
    """Imitates get_normal_name in tokenizer.c.

    Note:
        Copied without modification from Python 3.6.1 tokenize standard library module

        Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
        2011, 2012, 2013, 2014, 2015, 2016, 2017 Python Software Foundation; All Rights
        Reserved"

        See also py-cloud-compute-cannon/NOTICES.
    """
    # Only care about the first 12 characters.
    enc = orig_enc[:12].lower().replace("_", "-")
    if enc == "utf-8" or enc.startswith("utf-8-"):
        return "utf-8"
    if enc in ("latin-1", "iso-8859-1", "iso-latin-1") or \
       enc.startswith(("latin-1-", "iso-8859-1-", "iso-latin-1-")):
        return "iso-8859-1"
    return orig_enc