Carlo S
Carlo S

Reputation: 983

String to UTF8 Char Conversion in Objective-C

I'm trying to save an UTF8 char to a string and print it to a label.

If I hard code it works fine:

NSString *param = @"\uf02e";
NSLog(param);

Result:

2012-10-24 16:09:56.522 i[22996:12c03] 

By the way if I'm saving the char to a string I can't go back.

NSString *myString = [NSString stringWithFormat:@"%@",[item objectForKey:content]];
NSLog(myString);

Result:

2012-10-24 16:18:47.289 i[23105:12c03] \uf02e

Any solution for this? Thanks.

EDIT

item is an NSDictionary and [item objectForKey:content] is a string.

enter image description here

Upvotes: 0

Views: 679

Answers (1)

Max
Max

Reputation: 16719

    NSString *param = @"\uf02e";
    NSDictionary* item = [NSDictionary dictionaryWithObject: param forKey: @"key"];
    NSString *myString = [NSString stringWithFormat:@"%@",[item objectForKey: @"key"]];
    NSLog(myString);

Works fine for me. So the error is in the value, that you're inserting into the dictionary.

Upvotes: 1

Related Questions