textfile collector: updating utfbom dependency and simplifying code
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
This commit is contained in:
parent
f4e5bc3d29
commit
5f9dfcc378
|
@ -37,12 +37,12 @@
|
|||
revision = "4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:ec6271918b59b872a2d25e374569a4f75f1839d91e4191470c297b7eaaaf7641"
|
||||
digest = "1:f9adc21a937e5da643ea14a3488cb7506788876737a5e205394e508627a6eec8"
|
||||
name = "github.com/dimchansky/utfbom"
|
||||
packages = ["."]
|
||||
pruneopts = "NUT"
|
||||
revision = "5448fe645cb1964ba70ac8f9f2ffe975e61a536c"
|
||||
version = "v1.0.0"
|
||||
revision = "d2133a1ce379ef6fa992b0514a77146c60db9d1c"
|
||||
version = "v1.1.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:cb4e216bd9f58866f42dc65893455b24f879b026fdaa1ecc3aafff625fdb5a66"
|
||||
|
|
|
@ -288,19 +288,9 @@ fileLoop:
|
|||
}
|
||||
|
||||
func checkBOM(encoding utfbom.Encoding) error {
|
||||
bom := ""
|
||||
switch encoding {
|
||||
case utfbom.Unknown, utfbom.UTF8:
|
||||
if encoding == utfbom.Unknown || encoding == utfbom.UTF8 {
|
||||
return nil
|
||||
case utfbom.UTF16BigEndian:
|
||||
bom = "UTF16BigEndian"
|
||||
case utfbom.UTF16LittleEndian:
|
||||
bom = "UTF16LittleEndian"
|
||||
case utfbom.UTF32BigEndian:
|
||||
bom = "UTF32BigEndian"
|
||||
case utfbom.UTF32LittleEndian:
|
||||
bom = "UTF32LittleEndian"
|
||||
}
|
||||
|
||||
return fmt.Errorf(bom)
|
||||
return fmt.Errorf(encoding.String())
|
||||
}
|
||||
|
|
|
@ -32,6 +32,24 @@ const (
|
|||
UTF32LittleEndian
|
||||
)
|
||||
|
||||
// String returns a user-friendly string representation of the encoding. Satisfies fmt.Stringer interface.
|
||||
func (e Encoding) String() string {
|
||||
switch e {
|
||||
case UTF8:
|
||||
return "UTF8"
|
||||
case UTF16BigEndian:
|
||||
return "UTF16BigEndian"
|
||||
case UTF16LittleEndian:
|
||||
return "UTF16LittleEndian"
|
||||
case UTF32BigEndian:
|
||||
return "UTF32BigEndian"
|
||||
case UTF32LittleEndian:
|
||||
return "UTF32LittleEndian"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
const maxConsecutiveEmptyReads = 100
|
||||
|
||||
// Skip creates Reader which automatically detects BOM (Unicode Byte Order Mark) and removes it as necessary.
|
||||
|
|
Loading…
Reference in New Issue