base64
来源:互联网 发布:java发送带图片的邮件 编辑:程序博客网 时间:2024/09/21 09:23
base64解码和编码范例(iPhone和Mac通用) (在iOS代码库中浏览本帖)
请参考fly的blog
http://www.flyblog.info/catprogramming/376.html
和我的blog
http://www.cocoabob.net/?p=7
都是使用了一个叫Jonathan Wight的人在2003年3月18日写的Base64Transcoder。传播过程中丢失了版权信息,也把它改成了ObjC的文件命名。
另外,请不要用这个链接里所说的base64编解码器,测试下来,发现只能对字母和数字以及符号进行编解码,这种编解码器没法用来处理纯数据,只能用来处理纯文本。(希望我没有测试错误~)
http://www.cocoachina.com/bbs/read.php?tid-6485-page-e-fpage-1.html
示范代码在这
http://www.flyblog.info/catprogramming/376.html
和我的blog
http://www.cocoabob.net/?p=7
都是使用了一个叫Jonathan Wight的人在2003年3月18日写的Base64Transcoder。传播过程中丢失了版权信息,也把它改成了ObjC的文件命名。
另外,请不要用这个链接里所说的base64编解码器,测试下来,发现只能对字母和数字以及符号进行编解码,这种编解码器没法用来处理纯数据,只能用来处理纯文本。(希望我没有测试错误~)
http://www.cocoachina.com/bbs/read.php?tid-6485-page-e-fpage-1.html
示范代码在这
1
2
3
4
5
6
7
8
NSString
*stringValue =
/*the UTF8 string parsed from xml data*/
Byte inputData[[stringValue lengthOfBytesUsingEncoding:
NSUTF8StringEncoding
]];
//prepare a Byte[]
[[stringValue dataUsingEncoding:
NSUTF8StringEncoding
] getBytes:inputData];
//get the pointer of the data
size_t inputDataSize = (size_t)[stringValue length];
size_t outputDataSize = EstimateBas64DecodedDataSize(inputDataSize);
//calculate the decoded data size
Byte outputData[outputDataSize];
//prepare a Byte[] for the decoded data
Base64DecodeData(inputData, inputDataSize, outputData, &outputDataSize);
//decode the data
NSData
*theData = [[
NSData
alloc] initWithBytes:outputData length:outputDataSize];
//create a NSData object from the decoded data
[ 此帖被bobgreen在2010-08-16 18:21重新编辑 ]
附件: base64.zip (3 K) 下载次数:1893
0 0
- base64
- BASE64
- Base64
- BASE64
- Base64
- Base64
- base64
- base64
- base64
- base64
- base64
- Base64
- base64
- base64
- Base64
- BASE64
- Base64
- Base64
- 【原创】k8s源码分析-----kube-proxy(2)ProxyServer
- 修复VirtualBox "This kernel requires the following features not present on the CPU: pae Unable to boot
- HTML5的新特性
- 【mahapps.metro】WPF窗体Dialogs(对话框)的使用
- tesseract的使用
- base64
- resizableImageWithCapInsets 图片拉伸
- Android中Service的使用详解和注意点(LocalService)
- 点光源
- ASP.NET中Dictionary如何转换为list
- dbms_metadata包中的get_ddl函数
- Android开发环境搭建(Windows+Eclipse)
- 发送POST请求数据包&解决发过去的中文在后台显示乱码"????"
- Android Studio:Gradle project refresh failed. Connection timed out: connect.