QRcodeViewController *qrViewC = [[QRcodeViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:qrViewC];
[strongSelfpresentViewController:nav animated:YES completion:nil];
qrViewC.resultQR= ^(NSString*info){
[strongSelfdismissViewControllerAnimated:YES completion:^{
NSString*result;
NSMutableArray*resultArray = [NSMutableArrayarray];
BOOLtopChinese = [MultiRolesTopChinese:info];
if(topChinese){
NSArray *array = [infocomponentsSeparatedByString:@"\r\n"];
resultArray = [NSMutableArrayarrayWithArray:array];
}else{
NSArray *array = [infocomponentsSeparatedByString:@"\r\n"];
for(inta=0;a
// NSData *data=[result dataUsingEncoding:NSUTF8StringEncoding];
NSData*data=[array[a]dataUsingEncoding:NSShiftJISStringEncoding];
NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
NSString*retStr = [[NSStringalloc]initWithData:dataencoding:enc];//如果中⽂文是utf-8编码转gbk结果为空
if([retStrisEqualToString:@""])//如果扫描中⽂文乱码则需要处理,否则不处理
{
NSIntegermax = [array[a]length];
char*nbytes =malloc(max +1);
for(inti =0; i < max; i++)
{
unicharch = [array[a]characterAtIndex: i];
nbytes[i] = (char) ch;
}
nbytes[max] ='\0';
result=[NSStringstringWithCString: nbytesencoding: enc];
}else{
result = retStr;
}
[resultArrayaddObject:result];
}
}
网友评论