Skip to content

Commit d1ae09d

Browse files
committed
fix: add utf8 encoder for outputter
1 parent 645e260 commit d1ae09d

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
github.com/urfave/cli/v2 v2.4.0
1717
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3
1818
golang.org/x/exp v0.0.0-20220414153411-bcd21879b8fd
19+
golang.org/x/text v0.3.6
1920
)
2021

2122
require (

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBc
9090
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
9191
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
9292
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
93+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
94+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
9395
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
9496
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
9597
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=

internal/browingdata/outputter.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99

1010
"github.com/gocarina/gocsv"
1111
jsoniter "github.com/json-iterator/go"
12+
"golang.org/x/text/encoding/unicode"
13+
"golang.org/x/text/transform"
1214
)
1315

1416
type OutPutter struct {
@@ -35,7 +37,7 @@ func (o *OutPutter) Write(data Source, writer io.Writer) error {
3537
return encoder.Encode(data)
3638
default:
3739
gocsv.SetCSVWriter(func(w io.Writer) *gocsv.SafeCSVWriter {
38-
writer := csv.NewWriter(w)
40+
writer := csv.NewWriter(transform.NewWriter(w, unicode.UTF8BOM.NewEncoder()))
3941
writer.Comma = ','
4042
return gocsv.NewSafeCSVWriter(writer)
4143
})

0 commit comments

Comments
 (0)