ios--base編碼NSDataBase64EncodingOptions

// 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

遇到記錄,分享~~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章