// Use zero or one of the following to control the maximum line length after which a line ending is inserted. No line endings are inserted by default.
NSDataBase64Encoding64CharacterLineLength =1UL<<0,
NSDataBase64Encoding76CharacterLineLength =1UL<<1,
// Use zero or more of the following to specify which kind of line ending is inserted. The default line ending is CR LF.
NSDataBase64EncodingEndLineWithCarriageReturn =1UL<<4,
NSDataBase64EncodingEndLineWithLineFeed =1UL<<5,
这个枚举NSDataBase64EncodingOptions,四个选项的意义。
NSDataBase64Encoding64CharacterLineLength:每64个字符插入\r或\n
NSDataBase64Encoding76CharacterLineLength:每76个字符插入\r或\n,标准中有要求是76个字符要换行,不过具体还是自己定
NSDataBase64EncodingEndLineWithCarriageReturn:插入字符为\r
NSDataBase64EncodingEndLineWithLineFeed:插入字符为\n
前两个选项为是否允许插入字符,以及多少个字符长度插入,两个可以选其一或者都不选。后两个选项代表要插入的具体字符。比如我们想76个字符后插入一个\r则可以
[plainData base64EncodedStringWithOptions:0];
//0则表示不插入任何字符
比如我们想76个字符后插入一个\r则可以
NSDataBase64Encoding76CharacterLineLength | NSDataBase64EncodingEndLineWithCarriageReturn
一般Android和ios再加上后台联调统一的话,一般选择NSDataBase64EncodingEndLineWithLineFeed
引用参考链接:
https://www.jianshu.com/p/8424b47cc8a2
遇到记录,分享~~