Skip to content

Commit

Permalink
Fix: remove begining BOM when unmarshing csv
Browse files Browse the repository at this point in the history
Change-Id: I8eb88964ef5daf553efb94c640892bcd02978eff
  • Loading branch information
jxskiss committed Sep 6, 2024
1 parent a8f3f54 commit a34c54c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions easy/ezmap/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"reflect"
"sort"
"unsafe"

"github.com/jxskiss/gopkg/v2/utils/strutil"
)

// MarshalCSV marshal map[string]any records to CSV encoding.
Expand Down Expand Up @@ -84,6 +86,7 @@ func UnmarshalCSVWithSeparator(data []byte, sep rune) ([]Map, error) {
if sep != ',' && sep != ';' && sep != '\t' {
return nil, fmt.Errorf("unsupported separator: %c", sep)
}
data = strutil.TrimBOM(data)
csvReader := csv.NewReader(bytes.NewReader(data))
csvReader.Comma = sep
records, err := csvReader.ReadAll()
Expand Down

0 comments on commit a34c54c

Please sign in to comment.