开发者

Blob data replace '+' with space

开发者 https://www.devze.com 2023-04-12 02:08 出处:网络
I have an iphone app that converts a image into NSData & then converts into base64 encoded string.

I have an iphone app that converts a image into NSData & then converts into base64 encoded string.

When this encoded string is submitted to server in server's database, while storing on server '+' gets converted into 'space' and so the decoder does not work prop开发者_开发技巧erly.

I guess the issue is with default encoding of table in database. Currently its latin, i tried changing it to UTF8 but problem still exits.

Any other encoding, please help


Of course - that has nothing to do with encoding. It is the format of the POST and GET parameters which creates a clash with base64. In http://en.wikipedia.org/wiki/Base64#Variants_summary_table you see alternatives which are designed to make base64 work with URLs etc.

One of these variants is "Base64 with URL and Filename Safe Alphabet (RFC 4648 'base64url' encoding)" which replaces the + with - and the / with _.

Another alternative would be to replace the offending characters +/= by their respective hexrepresentations with %xx - but that makes the data unnecessarily longer.

0

精彩评论

暂无评论...
验证码 换一张
取 消