Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About Python-chardet iso-8859-9-turkish file encoding test exception #179

Open
PCwangPY opened this issue Jul 30, 2019 · 0 comments
Open

Comments

@PCwangPY
Copy link

Use the chardet.detect(data) function to check the iso-8859-9-turkish file encoding

Test steps:

  1. Write test code: chardet_test.py
          #!/usr/bin/python

      import sys
      import chardet

     path = str(sys.argv[1])
     f = open(path,'rb')
     data = f.read()
     s= chardet.detect(data)
     print(s)

  1. Test run: ./chardet_test.py divxplanet.com.xml
  2. Operation results:
         {'confidence': 0.73, 'language': '', 'encoding': 'ISO-8859-1'}
         The above result is obviously not "ISO-8859-9"

Desired result:
[root@localhost iso-8859-9-turkish]# ./chardet_test.py divxplanet.com.xml
{'confidence': 0.53159569353908, 'language': 'Turkish', 'encoding': 'ISO-8859-9'}

Through analysis: guess in the universaldetector.py file, judge the branch has objections

If we're checking non-CJK encodings, use single-byte prober

If self.lang_filter & LanguageFilter.NON_CJK:
self._charset_probers.append(SBCSGroupProber())
Self._charset_probers.append(Latin1Prober())
(The above 4 lines are the code)

I am not sure that it is caused by some reason, or it is a bug. Please give me a solution to this problem. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant