Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.4.0
version: v2.9.0
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/slash3b/utfbom

go 1.25
go 1.26

require github.com/nalgeon/be v0.2.0
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
This is a **fork** of [github.com/dimchansky/utfbom](https://github.com/dimchansky/utfbom).

# utfbom
[![Godoc](https://godoc.org/github.com/slash3b/utfbom?status.png)](https://godoc.org/github.com/slash3b/utfbom)
[![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0)
Expand Down
9 changes: 2 additions & 7 deletions utfbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"bytes"
"errors"
"io"
"slices"
"sync"
)

Expand Down Expand Up @@ -92,13 +93,7 @@ func DetectEncoding[T ~string | ~[]byte](input T) Encoding {
// AnyOf reports whether the Encoding value equals any of the given Encoding values.
// It returns true if a match is found, otherwise false.
func (e Encoding) AnyOf(es ...Encoding) bool {
for _, enc := range es {
if enc == e {
return true
}
}

return false
return slices.Contains(es, e)
}

// String returns the human-readable name of the encoding.
Expand Down
6 changes: 3 additions & 3 deletions utfbom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,21 @@ func ExampleReader() {
urd := utfbom.NewReader(bytes.NewReader([]byte(csvFile)))
crd := csv.NewReader(urd)

out := ""
var out strings.Builder
for {
row, err := crd.Read()
if err != nil {
break
}

out += strings.Join(row, ",")
out.WriteString(strings.Join(row, ","))
}

fmt.Println("detected encoding:", urd.Enc)
fmt.Println("before")
fmt.Println(hex.Dump([]byte(csvFile)))
fmt.Println("after")
fmt.Println(hex.Dump([]byte(out)))
fmt.Println(hex.Dump([]byte(out.String())))

// output:
//detected encoding: UTF8
Expand Down