新浪微博字数统计,中文字符为一个长度,英文、数字、标点符号2个为一个长度。而NSString的length方法无论是中文英文数字还是标点符号通过都返回1。
在做数字统计的时候第一个想到的是用正则表达式去实现(IOS常用正则表达式)。查了一下,正则表达式的话只返回该字符串中是否包含指定规则的文字,并不能统计字符串中有多少个中文。
其实后来想想也是可以的,用正则表达式规则 for 一下字符串的每一...
分类:
其他好文 时间:
2014-08-15 21:10:29
阅读次数:
246
以下样例代码可以列举出所有系统支持的Unicode编码。 #import int main() { @autoreleasepool{ NSStringEncoding const *list = [NSString availableStringEncodings]; NSStringEncoding encoding; while((encod...
分类:
移动开发 时间:
2014-08-15 18:09:49
阅读次数:
276
1,创建字符串,有@都是对象。NSString *myString1 = @"My String One”;将一个utf8编码的字符串实例化成对象NSString *myString2 = [NSString stringWithUTF8String:"My String Two"];第三种写法NS...
分类:
其他好文 时间:
2014-08-15 14:25:48
阅读次数:
289
char name[20] = "";存储用户名
char code[20] = "";存储密码
printf("请输入用户名与密码");
scanf("%s%s", name, code);
NSString *str1 = [NSString stringWithFormat:@"%s", name ]...
分类:
编程语言 时间:
2014-08-15 09:33:17
阅读次数:
370
1,创建对象的两种方法stringWithFormatinitWithFormat2,求字符串长度lengthNSUIntegerleng=[strlength]3,获取字符串的某个字符characterAtIndex:unicharleng=[strcharacterAtIndex:];4,判断是否以指定的字符串开头或结尾开头:BOOLisPrefix=[strhasPrefix:@"http"];结尾:BOOLisS..
分类:
其他好文 时间:
2014-08-15 02:56:27
阅读次数:
174
转载自:http://www.2cto.com/kf/201210/162333.html网上搜索出来的,记录下来以后使用方便:[java]//手机序列号 NSString* identifierNumber = [[UIDevice currentDevice] uniqueIdentifier]...
分类:
移动开发 时间:
2014-08-14 20:29:19
阅读次数:
207
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{ if (textField == _work.....
分类:
其他好文 时间:
2014-08-14 15:52:18
阅读次数:
212
//////第一种方法
// NSMutableArray *arr = [NSMutableArray array];
// for (int i = 0; i < 13; i ++) {
// [arr addObject:[NSString stringWithFormat:@"lanou%d",i + 1]];
// }
//...
分类:
其他好文 时间:
2014-08-14 01:36:17
阅读次数:
209
//iOS7和其他系统版本跳转链接不一样- (void)clickUrl:(id)sender{ UIButton *bt = (UIButton *)sender; NSString *str = @""; if( ([[[UIDevice currentDevi...
分类:
移动开发 时间:
2014-08-14 01:05:37
阅读次数:
254
.h#import@interfaceUIWebView(JavaScriptAlert)-(void)webView:(UIWebView*)senderrunJavaScriptAlertPanelWithMessage:(NSString*)messageinitiatedByFrame:(W...
分类:
Web程序 时间:
2014-08-13 21:56:07
阅读次数:
306