更新时间:2023-02-24 14:57:07
我猜他们是不同的编码.
I guess that they are of different encoding.
我运行了这个实验,看到如果编码不同,它会返回NO
.因此,尝试使用以下代码将 parseGrillId
转换为 utf8
.
I have run this experiment and see that if the encoding is different, it will return NO
. So, try converting parseGrillId
to utf8
with the code below.
NSString *s1 = [NSString stringWithCString:"HELLO123" encoding:NSUTF8StringEncoding];
NSString *s2 = [NSString stringWithCString:"HELLO123" encoding:NSUTF16StringEncoding];
NSString *s3 = [NSString stringWithUTF8String:s2.UTF8String];
if ([s1 isEqualToString:s2]) {
NSLog(@"s1 == s2");
}
if ([s1 isEqualToString:s3]) {
NSLog(@"s1 == s3");
}
将打印s1 == s3
.