code: def normalize_encoding(sample, encoding):
      
      encoding = codecs.lookup(encoding).name
      # Work around 'Incorrect detection of utf-8-sig encoding'
      # <https://github.com/PyYoshi/cChardet/issues/28>
      if encoding == 'utf-8':
          if sample.startswith(codecs.BOM_UTF8):
              encoding = 'utf-8-sig'
      # Use the BOM stripping name (without byte-order) for UTF-16 encodings
      elif encoding == 'utf-16-be':
          if sample.startswith(codecs.BOM_UTF16_BE):
              encoding = 'utf-16'
      elif encoding == 'utf-16-le':
          if sample.startswith(codecs.BOM_UTF16_LE):
              encoding = 'utf-16'
      return encoding
docs: Normalize encoding including 'utf-8-sig', 'utf-16-be', utf-16-le tweaks.