使用stringWithContentsOfUrl时,我在html源代码中丢失了%

时间:2012-08-12 13:35:34

标签: iphone html objective-c xcode nsstring

NSString *htmlSource = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:0x80000000 + kCFStringEncodingDOSKorean error:nil];
 NSLog(htmlSource);

我得到html结果标签(col width =“16”/)~~~但真正的html标签是(col width =“16%”/)

%字符消失。什么是问题?

1 个答案:

答案 0 :(得分:1)

字符串可能仍包含%; NSLog() 本身%符号具有特殊意义(考虑如果您使用%@%d等会发生什么。)。

尝试这样做:NSLog(@"%@", htmlSource);这将仅记录一个对象(字符串)并使其远离格式化参数。