我知道 ✭star 和 ♦ diamond 都来自 ASCII 扩展字符集。但是 iOS 上是否有一些可用的 NScharacterSet 可以用来以编程方式检查这些字符?
问问题
220 次
2 回答
0
This can be done with the NSString object method: rangeOfCharacterFromSet. It returns NSRange object.
From that,
Eg.:
NSCharacterSet *charSet = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789"] invertedSet];
NSString *string = @"Stach✭Overflow";
NSRange range = [string rangeOfCharacterFromSet:charSet];
if(range.location != NSNotFound) {
// one of those characters is exists in the string.
}else{
//no specifiedcharacter not found.
}
于 2013-04-25T07:05:12.910 回答
0
您可以使用字符集显示这些符号ISO 8859-1 or UTF-8.
[ ★ ] star solid [ number: ★]
[ ♦ ] black diamond suit [name: ♦] [number: ♦]
于 2013-04-24T02:48:52.030 回答