NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSCharacterSet *controlChars = [NSCharacterSet controlCharacterSet];
NSRange range = [responseString rangeOfCharacterFromSet:controlChars];
if (range.location != NSNotFound)
{
NSMutableString *mutable = [NSMutableString stringWithString:responseString];
while (range.location != NSNotFound)
{
[mutable deleteCharactersInRange:range];
range = [mutable rangeOfCharacterFromSet:controlChars];
}
responseString = mutable;
}
data = [responseString dataUsingEncoding:NSUTF8StringEncoding];
选择并删除其中的制表符,转化为UTF-8格式数据
网友评论