Objective c 如何将Unicode值转换为字符串目标C

Objective c 如何将Unicode值转换为字符串目标C,objective-c,unicode,Objective C,Unicode,我希望得到字符的实际unicode值,并将其放入转义字符串中。我将NSButton的标题设置为±,现在我正在尝试获取此按钮的标题并将其转换回此“\U00B1” 比如说 unichar theChar = [theButton.title characterAtIndex:0]; //now how would I change the above unichar to an string like @"\\u03b2" 一种解决办法是: unichar theChar = ... NSStr

我希望得到字符的实际unicode值,并将其放入转义字符串中。我将NSButton的标题设置为±,现在我正在尝试获取此按钮的标题并将其转换回此“\U00B1”

比如说

unichar theChar = [theButton.title characterAtIndex:0];
//now how would I change the above unichar to an string like @"\\u03b2"
一种解决办法是:

unichar theChar = ... 
NSString *escapeCode = [NSString stringWithFormat:@"\\\\u%04x", theChar];

请注意,您需要四个反斜杠才能在结果字符串中得到两个反斜杠。

谢谢,这正是我想要的