//将十六进制字符串转换成汉字
- (NSString)changeLanguage:(NSString)chinese{
NSString *strResult;
NSLog(@"chinese:%@",chinese);
if (chinese.length%2==0) {
//第二次转换
NSData *newData = [self hexToByteToNSData:chinese];
unsigned long encode = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
strResult = [[NSString alloc] initWithData:newData encoding:encode];
NSLog(@"strResult:%@",strResult);
}else{
NSString *strResult = @"已假定是汉字的转换,所传字符串的长度必须是4的倍数!";
NSLog(@"%@",strResult);
return NULL;
}
return strResult;
}
网友评论