I'm trying to see if I can connect to https://www.google.com with:
do {
let s = try String(contentsOf: URL(string: "https://www.google.com/")!, encoding: .utf8)
print(s)
} catch {
print(error)
}
The error I receive is:
Error Domain=NSCocoaErrorDomain Code=261 "The file couldn’t be opened using text encoding Unicode (UTF-8)." UserInfo={NSURL=https://www.google.com/, NSStringEncoding=4}
Viewing the page info on https://www.google.com states that it is using UTF-8:
Why is it always throwing an error?