//方法一:
-(int)convertToInt:(NSString*)strtemp {
intstrlength =0;
char* p = (char*)[strtempcStringUsingEncoding:NSUnicodeStringEncoding];
for(inti=0; i < [strtemplengthOfBytesUsingEncoding:NSUnicodeStringEncoding] ;i++) {
if( *p ){
p++;
strlength++;
}else{
p++;
}
}
returnstrlength;
}
//方法二:
- (int)getToInt:(NSString*)strtemp {
NSStringEncodingenc =CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
NSData* da = [strtempdataUsingEncoding:enc];
return(int)[dalength];
}