I need to download some big html files (about 300k+). Everything is working fine, the problem is that some of the files comes with Windows-1252/ISO-8859 characters like "á" or "ç" and when I save the document, Go converts it to characters like �. Any idea?
My code as follow:
package main
import (
"io"
"net/http"
"os"
)
func main() {
pagina := "http://www.mypage.com/doc?someparameters=123"
err := DownloadFile("doc.html", pagina)
if err != nil {
panic(err)
}
}
func DownloadFile(filepath string, url string) error {
out, err := os.Create(filepath)
if err != nil {
return err
}
defer out.Close()
resp, err := http.Get(url)
if err != nil {
return err
}
defer resp.Body.Close()
_, err = io.Copy(out, resp.Body)
if err != nil {
return err
}
return nil
}