This String is base64 encoded string:
NSString *string=@"ë§ë ë¼ì´";
This is not show the orginal string:
NSLog(@"String is %@",[string cStringUsingEncoding:NSMacOSRomanStringEncoding]);
This String is base64 encoded string:
NSString *string=@"ë§ë ë¼ì´";
This is not show the orginal string:
NSLog(@"String is %@",[string cStringUsingEncoding:NSMacOSRomanStringEncoding]);
That would be because Mac OS Roman is nothing like base-64 encoding. Base-64 encoding is a further encoding applied the bytes that represent the original string. If you want to see the original string, you will first need to base-64 decode the bytestring and then figure out the original string encoding in order to interpret it.
That's not a Base64-encoded string. There are a couple other things going on with your code, too:
You can't include literal non-ASCII characters inside a string constant; rather, you have to use the bytes that make up the character, prefixed with \x
; or in the case of Unicode, you can use the Unicode code point, prefixed with \u
. So your string should look something like NSString *string = @"\x91\xa4\x91 \x91\x93";
. But...
The characters ¼
and ´
aren't part of the MacRoman encoding, so you'll have trouble using them. Are you sure you want a MacRoman string, rather than a Unicode string? Not many applications use MacRoman anymore, anyway.
cStringUsingEncoding:
returns a C string, which should be printed with %s
, not %@
, since it's not an Objective-C object.
That said, your code will sort of work with:
// Using MacRoman encoding in string constant
NSString *s = @"\x91\xa4\x91 \x91\x93";
NSLog(@"%s", [s cStringUsingEncoding:NSMacOSRomanStringEncoding]);
I say "sort of work" because, again, you can't represent that code in MacRoman.