alexmullins / zip

Fork of Go's archive/zip to add reading/writing of password protected zip files.
MIT License
245 stars 143 forks source link

Chinese garbled characters #19

Closed loveyu233 closed 2 months ago

loveyu233 commented 2 months ago

The file name is garbled in Chinese, and the file content is not garbled in Chinese

func TestAl(t *testing.T) { contents := []byte("Hello World") fzip, err := os.Create(./test.zip) if err != nil { log.Fatalln(err) } zipw := zip.NewWriter(fzip)

defer zipw.Close()
w, err := zipw.Encrypt("乱码.txt", `golang`)
if err != nil {
    log.Fatal(err)
}

var buffer bytes.Buffer
buffer.Write(contents)
_, err = io.Copy(w, bytes.NewReader(buffer.Bytes()))

if err != nil {
    log.Fatal(err)
}
zipw.Flush()

}