https://github.com/goark/utf8bom
Strip leading UTF-8 BOM
https://github.com/goark/utf8bom
Last synced: 6 months ago
JSON representation
Strip leading UTF-8 BOM
- Host: GitHub
- URL: https://github.com/goark/utf8bom
- Owner: goark
- License: mit
- Created: 2022-11-04T08:10:17.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-04T11:42:27.000Z (over 3 years ago)
- Last Synced: 2024-09-25T09:32:56.810Z (almost 2 years ago)
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# utf8bom -- Strip leading UTF-8 BOM (Byte Order Mark)
[](https://github.com/goark/utf8bom/actions)
[](https://github.com/goark/utf8bom/actions)
[](https://raw.githubusercontent.com/goark/utf8bom/master/LICENSE)
[](https://github.com/goark/utf8bom/releases/latest)
This package is forked from [github.com/spkg/bom](https://github.com/spkg/bom) package.
## Usage
### Import
```go
import "github.com/goark/utf8bom"
```
### Strip leading UTF-8 BOM
```go
rc, err := func(path string) (io.ReadCloser, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
return utf8bom.Strip(file), nil
}("testdata/sample.txt")
if err != nil {
return
}
defer rc.Close()
b, err := io.ReadAll(rc)
if err != nil {
return
}
fmt.Println(string(b))
// Output:
// hello
```
[utf8bom]: https://github.com/goark/utf8bom "Strip leading UTF-8 BOM"