gpt4 book ai didi

ios - 如何比较 objective-c 中的 unicode 字符?

转载 作者:行者123 更新时间:2023-11-29 11:19:27 26 4
gpt4 key购买 nike

我正在尝试比较我应用中的 unicode 字符,,

当我使用

if([str charcterAtIndex:i] == 'w')
nslog......

它正常工作

但当字母是一个阿拉伯字母时,它就不会像 'ب' !!!

有没有具体的方法..

谢谢

最佳答案

你应该让它们成为 UTF-8

const char* utfStr1 = [yourString UTF8String];
const char* utfStr2 = [yourString2 UTF8String];

然后比较它们

if([utfStr1 isEqualToString:utfStr2]) NSLog(@"true");

关于ios - 如何比较 objective-c 中的 unicode 字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7967196/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com