With Data (not NSData), in fact how actually do you make a utf8 version of a jpeg?

后端 未结 1 1366
感情败类
感情败类 2021-01-24 01:40

Exactly as explained here, https://stackoverflow.com/a/30624755/294884

[It is a mistake to think that] the JPEG representation of an image is a UTF-8-encoded

相关标签:
1条回答
  • 2021-01-24 02:16

    This line has a problem:

    let mystere = trueBinary.count.base64EncodedString(
                  options: .lineLength76Characters)
    

    The problem is that trueBinary is a Data, and trueBinary.count is an Int, and Int doesn't have a base64EncodedString method. You want this:

    let mystere = trueBinary.base64EncodedString(
                  options: .lineLength76Characters)
    

    As for ‘the "lineLength" concept’: you don't have to specify a line length option if you don't want to. Arguably I shouldn't have specified one in the answer you referenced in your question, because HTTP requests are not strictly MIME messages and are not subject to the MIME line length limit. You can do this instead:

    let mystere = trueBinary.base64EncodedString()
    
    0 讨论(0)
提交回复
热议问题