System.perspective.download Encoding

The problem is probably with httpGet, not system.perspective.download - once you’re downloading the file, there’s no encoding.

Since you’re already in 8.0, I would highly recommend migrating to system.net.httpClient.
Unlike httpGet, it will try to use the charset from the Content-Type header in the response - and if one is not found, it falls back to UTF-8, instead of the platform’s default charset (which is UTF-8 on basically every platform except Windows), as system.net.httpGet() does.

It would be a drop in replacement for the existing code you have:

uri = 'https://www.googleapis.com/drive/v3/files/1-fS4Bgy7NCdM8Frsed1YNOTaR_8majxm?alt=media'
headers = {'Authorization': 'Bearer ' + access_token}
file = system.net.httpClient().get(uri, headers=headers).body
# file = system.net.httpGet(url = uri, headerValues = headers)
2 Likes