Skip to content

Commit

Permalink
Add reset() method to EncodingDetector
Browse files Browse the repository at this point in the history
  • Loading branch information
phoerious committed Mar 6, 2023
1 parent 310aa25 commit a43df7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions resiliparse/resiliparse/parse/encoding.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cdef class EncodingDetector:

cpdef void update(self, const string& data)
cpdef str encoding(self, bint html5_compatible=*)
cpdef void reset(self)

cpdef str detect_encoding(bytes data, size_t max_len=*, bint html5_compatible=*, bint from_html_meta=*)
cpdef str bytes_to_str(bytes data, str encoding=*, str errors=*, fallback_encodings=*, bint strip_bom=*)
Expand Down
8 changes: 8 additions & 0 deletions resiliparse/resiliparse/parse/encoding.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ cdef class EncodingDetector:

return enc

cpdef void reset(self):
"""
reset(self)
Manually reset the encoding detector state.
"""
uchardet_reset(self.d)

def __dealloc__(self):
if self.d != NULL:
uchardet_delete(self.d)
Expand Down

0 comments on commit a43df7a

Please sign in to comment.