Joungkyun / libchardet

libchardet - Mozilla's Universal Charset Detector C/C++ API
Other
105 stars 33 forks source link

can't detect utf-16 and utf-32 #8

Closed Joungkyun closed 8 years ago

Joungkyun commented 8 years ago

can't detect utf-16 and utf-32

Joungkyun commented 8 years ago

The cause of this bug is because detect and detect_handledata APIs are not binary safe.

These APIs used strlen() internally. If given strings are UTF-16 or UTF-32 that has BOM code, binary safe problem occurs.

To fix this problems, change prototype of these APIs as follows:

CHARDET_API short detecthandledata (Detect *, const char , size_t, DetectObj _)

However, for comaptibility with old version, add new detect_handledata_r and detect_r APIs

So, don't use detect and detect_handledata APIs and replace to detect_r or detect_handledata_r.