- (NSMutableString*)randomCreatChinese:(NSInteger)count{
NSMutableString*randomChineseString =@"".mutableCopy;
for(NSIntegeri =0; i < count; i++){
NSStringEncodinggbkEncoding =CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
//随机生成汉字高位
NSIntegerrandomH =0xA1+arc4random()%(0xFE-0xA1+1);
//随机生成汉子低位
NSIntegerrandomL =0xB0+arc4random()%(0xF7-0xB0+1);
//组合生成随机汉字
NSIntegernumber = (randomH<<8)+randomL;
NSData*data = [NSDatadataWithBytes:&numberlength:2];
NSString*string = [[NSStringalloc]initWithData:dataencoding:gbkEncoding];
[randomChineseStringappendString:string];
}
returnrandomChineseString;
}
网友评论