Add support for UTF-8 w/ BOM

This commit is contained in:
Joren 2024-09-06 14:36:46 +02:00
parent 4cbd64f263
commit 077f1efb6f
Signed by: Joren
GPG Key ID: 280E33DFBC0F1B55

View File

@ -24,6 +24,8 @@ func processInputFile(inputFile string) error {
return fmt.Errorf("error reading file %s: %v", inputFile, err)
}
byteValue = removeBOM(byteValue)
var items Items
err = json.Unmarshal(byteValue, &items)
if err != nil {
@ -42,6 +44,13 @@ func processInputFile(inputFile string) error {
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 {
fmt.Println("Downloading:", item.Filename)