package utfbom
import "github.com/dimchansky/utfbom"
Package utfbom implements the detection of the BOM (Unicode Byte Order Mark) and removing as necessary. It wraps an io.Reader object, creating another object (Reader) that also implements the io.Reader interface but provides automatic BOM checking and removing as necessary.
Index ¶
Functions ¶
func Skip ¶
Skip creates Reader which automatically detects BOM (Unicode Byte Order Mark) and removes it as necessary. It also returns the encoding detected by the BOM. If the detected encoding is not needed, you can call the SkipOnly function.
Types ¶
type Encoding ¶
type Encoding int
Encoding is type alias for detected UTF encoding.
const ( // Unknown encoding, returned when no BOM was detected Unknown Encoding = iota // UTF8, BOM bytes: EF BB BF UTF8 // UTF-16, big-endian, BOM bytes: FE FF UTF16BigEndian // UTF-16, little-endian, BOM bytes: FF FE UTF16LittleEndian // UTF-32, big-endian, BOM bytes: 00 00 FE FF UTF32BigEndian // UTF-32, little-endian, BOM bytes: FF FE 00 00 UTF32LittleEndian )
Constants to identify detected UTF encodings.
func (Encoding) String ¶
String returns a user-friendly string representation of the encoding. Satisfies fmt.Stringer interface.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader implements automatic BOM (Unicode Byte Order Mark) checking and removing as necessary for an io.Reader object.
func SkipOnly ¶
SkipOnly creates Reader which automatically detects BOM (Unicode Byte Order Mark) and removes it as necessary.
func (*Reader) Read ¶
Read is an implementation of io.Reader interface. The bytes are taken from the underlying Reader, but it checks for BOMs, removing them as necessary.
Source Files ¶
- Version
- v1.1.1 (latest)
- Published
- Nov 6, 2020
- Platform
- darwin/amd64
- Imports
- 2 packages
- Last checked
- 11 months ago –
Tools for package owners.