- void test2(){
- NSString *path = @"/Users/gx/Desktop/test_utf8.txt";
-
-
- NSString *str = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
- NSLog(@"%@",str);
-
-
- NSString *path2 = @"/Users/gx/Desktop/test_gbk.txt";
- NSString *str2 = [NSString stringWithContentsOfFile:path2 encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000) error:nil];
- NSLog(@"%@",str2);
-
-
- NSURL *url = [NSURL URLWithString:@"file:///Users/gx/Desktop/test_utf8.txt"];
- NSString *str3 = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
- NSLog(@"%@",str3);
-
-
- NSURL *url2 = [NSURL URLWithString:@"http://www.baidu.com"];
- NSString *str4 = [NSString stringWithContentsOfURL:url2 encoding:NSUTF8StringEncoding error:nil];
- NSLog(@"%@",str4);
- }