Created
March 16, 2019 14:18
-
-
Save lzjluzijie/088b8f11fca5a33f0be766cbd7970ede to your computer and use it in GitHub Desktop.
GB18030 zip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"archive/zip" | |
"github.com/saintfish/chardet" | |
"golang.org/x/text/encoding/simplifiedchinese" | |
"log" | |
"os" | |
) | |
func main() { | |
path := os.Args[1] | |
r, err := zip.OpenReader(path) | |
if err != nil { | |
log.Fatal(err) | |
} | |
for _, f := range r.File { | |
rs, err := chardet.NewTextDetector().DetectAll([]byte(f.Name)) | |
if err != nil { | |
panic(err) | |
} | |
g, err := simplifiedchinese.GB18030.NewDecoder().String(f.Name) | |
if err != nil { | |
panic(err) | |
} | |
log.Printf("%s: %s %v", f.Name,g, rs) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment