Base64 decoded returning nil swift

Alex

I'm trying to decode a base64 type to String, but the content is always nil. There is how im getting the data from the json. String :

IyBTd2lmdHlKU09OCgpbIVtDYXJ0aGFnZSBjb21wYXRpYmxlXShodHRwczov\nL2ltZy5zaGllbGRzLmlvL2JhZGdlL0NhcnRoYWdlLWNvbXBhdGlibGUtNEJD\nNTFELnN2Zz9zdHlsZT1mbGF0KV0oaHR0cHM6Ly9naXRodWIuY29tL0NhcnRo\nYWdlL0NhcnRoYWdlKSAhW0NvY29hUG9kc10oaHR0cHM6Ly9pbWcuc2hpZWxk\ncy5pby9jb2NvYXBvZHMvdi9Td2lmdHlKU09OLnN2ZykgIVtQbGF0Zm9ybV0o\naHR0cHM6Ly9pbWcuc2hpZWxkcy5pby9iYWRnZS9wbGF0Zm9ybXMtaU9TJTIw\nOC4wJTIwJTdDJTIwbWFjT1MlMjAxMC4xMCUyMCU3QyUyMHR2T1MlMjA5LjAl\nMjAlN0MlMjB3YXRjaE9TJTIwMy4wLUYyOEQwMC5zdmcpIFshW1Jldmlld2Vk\nIGJ5IEhvdW5kXShodHRwczovL2ltZy5zaGllbGRzLmlvL2JhZGdlL1Jldmll\nd2VkX2J5LUhvdW5kLThFNjRCMC5zdmcpXShodHRwczovL2hvdW5kY2kuY29t\nKQoKU3dpZnR5SlNPTiBtYWtlcyBpdCBlYXN5IHRvIGRlYWwgd2l0aCBKU09O\nIGRhdGEgaW4gU3dpZnQuCgpQbGF0Zm9ybSB8IEJ1aWxkIFN0YXR1cwotLS0t\nLS0tLS18IC0tLS0tLS0tLS0tLS0tfCAKKk9TICAgICAgfCBbIVtUcmF2aXMg\nQ0ldKGh0dHBzOi8vdHJhdmlzLWNpLm9yZy9Td2lmdHlKU09OL1N3aWZ0eUpT\nT04uc3ZnP2JyYW5jaD1tYXN0ZXIpXShodHRwczovL3RyYXZpcy1jaS5vcmcv\nU3dpZnR5SlNPTi9Td2lmdHlKU09OKSAgICB8IApbTGludXhdKGh0dHBzOi8v\nZ2l0aHVi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c3Vs\ndCBpbgogICAgc3dpdGNoIHJlc3VsdCB7CiAgICBjYXNlIGxldCAuc3VjY2Vz\ncyhtb3lhUmVzcG9uc2UpOgogICAgICAgIGxldCBkYXRhID0gbW95YVJlc3Bv\nbnNlLmRhdGEKICAgICAgICBsZXQganNvbiA9IEpTT04oZGF0YTogZGF0YSkg\nLy8gY29udmVydCBuZXR3b3JrIGRhdGEgdG8ganNvbgogICAgICAgIHByaW50\nKGpzb24pCiAgICBjYXNlIGxldCAuZmFpbHVyZShlcnJvcik6CiAgICAgICAg\ncHJpbnQoImVycm9yOiBcKGVycm9yKSIpCiAgICB9Cn0KCmBgYAoKIyMgU3dp\nZnR5SlNPTiBNb2RlbCBHZW5lcmF0b3IKVG9vbHMgdG8gZ2VuZXJhdGUgU3dp\nZnR5SlNPTiBNb2RlbHMKKiBbSlNPTiBDYWZlXShodHRwOi8vd3d3Lmpzb25j\nYWZlLmNvbS8pCiogW0pTT04gRXhwb3J0XShodHRwczovL2dpdGh1Yi5jb20v\nQWhtZWQtQWxpL0pTT05FeHBvcnQpCg==\n
func downloadJSON (completed: @escaping () -> ()) {
    let url = URL (string: "https://api.github.com/repos/\(details!.full_name)/readme")
    URLSession.shared.dataTask(with: url!) { (data, response, error) in
        if error == nil {
            do {
                print("ceva")
                self.read = try JSONDecoder().decode(Readm.self, from: data!)
                DispatchQueue.main.async {
                    completed()
                }
            } catch {
                print (error)
            }
            
        }
    }.resume()
}

Here is my func base64, I put a breakpoint at the return String, but the code is never executed , probably goes on the branch " return nil"

func base64Decoded(word: String) -> String? {
    guard let base64Data = Data(base64Encoded: word) else { return nil}
    return String(data: base64Data, encoding: .utf8)
}

This is how I'm doing the call

downloadJSON {
    if let content = self.read?.content {
        self.readMeLabel.text = self.base64Decoded(word: content)
    }
}

EDITED: I added the following function :

func base64Encoded(word: String) -> String? {
        let base64Encoded = word.data(using: String.Encoding.utf8)?.base64EncodedString()
        return base64Encoded
    }

And modified the content of downloadJSON from

if let content = self.read?.content {
        self.readMeLabel.text = self.base64Decoded(word: content)
    }

To

downloadJSON {
            if let content = self.base64Encoded(word: self.read!.content) {
              self.readMeLabel.text = self.base64Decoded(word: content)
           }

Now, my return string from the base64Decoded is working, but in the readMeLabel is showing the base64 , not the decoded one .

vadian

After you've added the encoded string (at last) you can see immediately that it contains linefeed characters (\n), so you have to specify the ignoreUnknownCharacters option

func base64Decoded(word: String) -> String? {
    guard let base64Data = Data(base64Encoded: word, options: .ignoreUnknownCharacters) else { return nil}
    return String(data: base64Data, encoding: .utf8)
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related