Add support for UTF-8 w/ BOM
This commit is contained in:
parent
4cbd64f263
commit
077f1efb6f
@ -24,6 +24,8 @@ func processInputFile(inputFile string) error {
|
|||||||
return fmt.Errorf("error reading file %s: %v", inputFile, err)
|
return fmt.Errorf("error reading file %s: %v", inputFile, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byteValue = removeBOM(byteValue)
|
||||||
|
|
||||||
var items Items
|
var items Items
|
||||||
err = json.Unmarshal(byteValue, &items)
|
err = json.Unmarshal(byteValue, &items)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -42,6 +44,13 @@ func processInputFile(inputFile string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeBOM(input []byte) []byte {
|
||||||
|
if len(input) >= 3 && input[0] == 0xEF && input[1] == 0xBB && input[2] == 0xBF {
|
||||||
|
return input[3:]
|
||||||
|
}
|
||||||
|
return input
|
||||||
|
}
|
||||||
|
|
||||||
func downloadFile(item Item) error {
|
func downloadFile(item Item) error {
|
||||||
fmt.Println("Downloading:", item.Filename)
|
fmt.Println("Downloading:", item.Filename)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user