1

I am using the base64 implementation at the bottom of this post.

If I use following code:

NSLog(@"decoded:%@",[[[NSString alloc] initWithData:[Base64 decode:@"8fEmIzEyNDA3OyYjMTI0MTE7"] encoding:NSUTF8StringEncoding] autorelease]);

I get decoded:(null)

However, if I use:

NSLog(@"decoded 1:%@",[[[NSString alloc] initWithData:[Base64 decode:@"8fEmIzEyNDA3OyYjMTI0MTE7"] encoding:NSASCIIStringEncoding] autorelease]);

I get decoded:ññぷほ

But I should get decoded:ññぷほ

What am I doing wrong?

Daniel
  • 20,420
  • 10
  • 92
  • 149
  • You can use - http://stackoverflow.com/questions/392464/any-base64-library-on-iphone-sdk – Sagar Oct 11 '10 at 12:35
  • ¬¬ that's what I am using.. if you follow the "this post" link you will get to the same page – Daniel Oct 11 '10 at 13:18

2 Answers2

2

Those are HTML character references. You'll need to decode further if you want raw text.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
0

You should read this article by Matt Gallagher. At the bottom there is link with code for iOS if that is what you are after.

It provides an class extension to NSData which is you string is easily converted from and too.

Thomas Anagrius
  • 926
  • 5
  • 15