Skip to content

Commit

Permalink
Always put u8 at the beginning of list (#19)
Browse files Browse the repository at this point in the history
Calling .first() should gave u8 if present.
  • Loading branch information
Ousret authored Oct 11, 2019
1 parent 62e32e7 commit 19d2075
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions charset_normalizer/normalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ def __init__(self, matches):
"""
self._matches = matches

if len(self) > 1 and 'utf_8' in self.could_be_from_charset:

u8_index = self.could_be_from_charset.index('utf_8')

# Put UTF_8 at the beginning if not already the case
if u8_index > 0:
self._matches.insert(1, self._matches.pop(u8_index))

def __iter__(self):
for elem in self._matches:
yield elem
Expand Down

0 comments on commit 19d2075

Please sign in to comment.