Documentation
¶
Overview ¶
Package utfutil provides methods that make it easy to read data in an UTF-encoding agnostic.
Index ¶
Constants ¶
View Source
const ( // UTF8 indicates the specified encoding. UTF8 EncodingHint = iota // UTF16LE indicates the specified encoding. UTF16LE // UTF16BE indicates the specified encoding. UTF16BE // WINDOWS indicates that the file came from a MS-Windows system WINDOWS = UTF16LE // POSIX indicates that the file came from Unix or Unix-like systems POSIX = UTF8 // HTML5 indicates that the file came from the web HTML5 = UTF8 )
Variables ¶
This section is empty.
Functions ¶
func BytesReader ¶
func BytesReader(b []byte, d EncodingHint) io.Reader
BytesReader is a convenience function that takes a []byte and decodes them to UTF-8.
func BytesWriter ¶
func BytesWriter(b *bytes.Buffer, d EncodingHint) io.Writer
Types ¶
type EncodingHint ¶
type EncodingHint int
EncodingHint indicates the file's encoding if there is no BOM.
type UTFReadCloser ¶
UTFReadCloser describes the utfutil ReadCloser structure.
func NewReader ¶
func NewReader(r io.Reader, d EncodingHint) UTFReadCloser
NewReader wraps a Reader to decode Unicode to UTF-8 as it reads.
func OpenFile ¶
func OpenFile(name string, d EncodingHint) (UTFReadCloser, error)
OpenFile is the equivalent of os.Open().
type UTFScanCloser ¶
type UTFScanCloser interface {
Buffer(buf []byte, max int)
Bytes() []byte
Err() error
Scan() bool
Split(split bufio.SplitFunc)
Text() string
Close() error
}
UTFScanCloser describes a new utfutil ScanCloser structure. It's similar to ReadCloser, but with a scanner instead of a reader.
func NewScanner ¶
func NewScanner(name string, d EncodingHint) (UTFScanCloser, error)
NewScanner is a convenience function that takes a filename and returns a scanner.
type UTFWriteCloser ¶
func NewWriter ¶
func NewWriter(r io.Writer, d EncodingHint) UTFWriteCloser
Click to show internal directories.
Click to hide internal directories.