我正在创建聊天应用程序。现在,我正在使用php web-service发送和检索数据。现在,我在将表情符号从android发送到iphone时遇到问题。当我发送笑脸表情符号时,它在iphone中显示出来as%Fo%9F%98%Fo%9F%98%Fo%9F%98。
我也转换为UTF8String。
NSMutableArray *arrreceiveMsg= [result objectForKey:@"newMessages"];
if ([arrreceiveMsg count] > 0)
{
arrreceiveMsg = [ShareOBJ filterArray:arrreceiveMsg WithClass:[Messages class]];
[arrreceiveMsg enumerateObjectsUsingBlock:^(Messages *obj, NSUInteger idx, BOOL *stop) {
obj.status = [NSNumber numberWithInt:Success];
obj.message = [NSString stringWithFormat:@"%s",[obj.message UTF8String]];
[obj updateInDB];
}];
答案 0 :(得分:3)
试试此代码
NSData *data = [aStrMessage dataUsingEncoding:NSNonLossyASCIIStringEncoding];
NSString *goodValue = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
//this one is for sending msg
NSData *data = [[aDictChat objectForKey:@"chat_message"] dataUsingEncoding:NSUTF8StringEncoding];
NSString *aStrChatMsg = [[NSString alloc] initWithData:data encoding:NSNonLossyASCIIStringEncoding];
//this one is for display msg in cell