albfernandez / juniversalchardet

Originally exported from code.google.com/p/juniversalchardet
Other
339 stars 60 forks source link

Please support detecting the encoding of a CSV file #38

Closed zhang13690 closed 4 years ago

zhang13690 commented 4 years ago

In a project, I need to detect the encoding of a CSV file.

CSV is a line by line text file, but when I saved a CSV file like this(using UTF-8 or GBK):

demo,
汉字(chinese),

juniversalchardet cannot detect the encoding.

Code :

String encoding = UniversalDetector.detectCharset(new File(myCsvFile));
 // the result of "encoding" is null

So is there a way to detect the encoding of a csv file?