# char-encode-detector **Repository Path**: linkiang/char-encode-detector ## Basic Information - **Project Name**: char-encode-detector - **Description**: a utility to detect char encode. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 6 - **Created**: 2016-02-15 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #char-encode-detector a utility to detect char encode. ## implemented detectors * GB2312 * GBK * UTF-8 ## all object are not thread safe. ## usage ``` byte[] bytes = "a号bc有".getBytes("gb2312"); DetectResult dr = new Detectors().detect(bytes).result(); assertThat("success percent should be 100%", dr.successPercent(), is(100)); assertThat("should detect 3 ascii chars", dr.getAsciiNumber(), is(3)); assertThat("charset name should be gb2312" ", dr.getCharsetName().toLowerCase(), is(true)); ``` 所有的配置在detect之前设置: ``` new Detectors().scanWholeFile().prefer(LanguageName.CHINESE).detect(somepath); ``` 完成的非常有限,欢迎fork和pullrequest。