I’m useing encoding/csv
to create csv file on my mac , but when I send it to a people who use windows, the content is garbled, I searched the reason and found it need write a bom-utf8 head, but it didn’t work
here is my code:
import (
"encoding/csv"
"log"
"os"
)
func main() {
file, err := os.Create("result.csv")
if err != nil {
log.Println(`create file error:`, err)
return
}
defer file.Close()
writer := csv.NewWriter(file)
bomUtf8 := []byte{0xEF, 0xBB, 0xBF}
writer.Write([]string{string(bomUtf8[:])})
writer.Write([]string{`当日资金净流入前十名币种`})
writer.Flush()
}