如何轉換十六進制值成表情符號圖標,我有一個字符串像下面的iOS轉換十六進制數值
NSString *myVal = @"1F61E";
我如何轉換這個文本,以顯示它的表情符號charrcaters?
我發現,價值from this link 請讓我知道,我真的卡住了這個問題
Updated
NSString *utf8String1 = @"1F61E";
NSString *a = [self convert:utf8String1];
NSLog(@"%@ &&&&&&&&&&&&&&&&&&&&&",a);
-(NSString*)convert:(NSString*)decoded{
unichar unicodeValue = (unichar) strtol([decoded UTF8String], NULL, 16);
char buffer[2];
int len = 1;
if (unicodeValue > 127) {
buffer[0] = (unicodeValue >> 8) & (1 << 8) - 1;
buffer[1] = unicodeValue & (1 << 8) - 1;
len = 2;
} else {
buffer[0] = unicodeValue;
}
return [[NSString alloc] initWithBytes:buffer length:len encoding:NSUTF8StringEncoding];
}
檢查所以這個答案,解釋正是這一點: http://stackoverflow.com/questions/1775859/how-to-convert-a- unichar-value-to-nsstring-in-objective-c – 2012-03-27 11:27:22