Last active
November 8, 2017 16:23
-
-
Save itiut/674d7ff87ede8207549c4c2e85975d72 to your computer and use it in GitHub Desktop.
`encoding/csv` reads UTF-8 BOM.
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 ( | |
"encoding/csv" | |
"fmt" | |
"log" | |
"os" | |
) | |
func main() { | |
file, err := os.Open("utf8bom.csv") | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer file.Close() | |
reader := csv.NewReader(file) | |
headers, err := reader.Read() | |
if err != nil { | |
log.Fatal(err) | |
} | |
fmt.Printf("%X\n", "col1") // => 636F6C31 | |
fmt.Printf("%X\n", headers[0]) // => EFBBBF636F6C31 | |
} |
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
col1 | col2 | |
---|---|---|
1 | 2 | |
3 | 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment