- (int)convertToInt:(NSString *)string
{
int strlength = 0;
char* p = (char*)[string cStringUsingEncoding:NSUnicodeStringEncoding];
for (int i=0 ; i<[string lengthOfBytesUsingEncoding:NSUnicodeStringEncoding] ;i++) {
if (*p) {
p++;
strlength++;
}
else {
p++;
}
}
return strlength;
}
- (int)chineseNumber:(NSString *)str
{
int t = 0;
for ( int i = 0; i < str.length; i++) {
unichar ch = [str characterAtIndex:i];
if (0x4e00 < ch && ch < 0x9fff)
{
t++;
}
}
return t;
}
- (BOOL)isPureNumandCharacters:(NSString *)string
{
string = [string stringByTrimmingCharactersInSet:[NSCharacterSet decimalDigitCharacterSet]];
if(string.length > 0)
{
return NO;
}
return YES;
}