title: Creating a zip archive with Unicode filenames using Go's archive/zip
body: <pre><code>package main
  
  import (
      "archive/zip"
      "fmt"
      "io"
      "os"
      "path/filepath"
      "strings"
  )
  
  func main() {
      var (
          Path = os.Args[1]
          Name = os.Args[2]
      )
  
      File, _ := os.Create(Name)
      PS := strings.Split(Path, "\\")
      PathName := strings.Join(PS[:len(PS)-1], "\\")
      os.Chdir(PathName)
      Path = PS[len(PS)-1]
      defer File.Close()
      Zip := zip.NewWriter(File)
      defer Zip.Close()
      walk := func(Path string, info os.FileInfo, err error) error {
          if err != nil {
              fmt.Println(err)
              return err
          }
          if info.IsDir() {
              return nil
          }
          Src, _ := os.Open(Path)
          defer Src.Close()
          fmt.Println(Path)
          FileName, _ := Zip.Create(Path)
          io.Copy(FileName, Src)
          Zip.Flush()
          return nil
      }
      if err := filepath.Walk(Path, walk); err != nil {
          fmt.Println(err)
      }
  }
  </code></pre>
  
  <p>This mydir path :</p>
  
  <pre><code>-----root
      |---2015-05(dir)
           |---中文.go
      |---package(dir)
      |---你好.go
  </code></pre>
  
  <p>When I use this code directory, Chinese will be garbled. Who can help me solve the problem.</p>