下面的url下载了一个没有扩展名的文件,包括总线和时间。这些数据是在一个iPhone应用程序中提取的,该应用程序显示名为mobitime的破解程序。问题是我找不到数据的编码是什么。有办法找到吗?
谢谢!
http://d2.mobitime.se/cgi/mtc/sad?uuid=01b07052fa390ceb845405e3d0547f7e&r=4&id=191430&no=721&to=Odensbacken%20via%20Ekeby Almby&lang=sv
我知道两种技术:
-
您可以查看HTTP标头,看看它是否报告了有用的内容:
NSURLRequest *request = [NSURLRequest requestWithURL:url]; NSOperationQueue *queue = [[NSOperationQueue alloc] init]; [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { if ([response isKindOfClass:[NSHTTPURLResponse class]]) { NSHTTPURLResponse *httpResponse = (id)response; NSLog(@"httpResponse.allHeaderFields = %@", httpResponse.allHeaderFields); } }];
这些头报告
"Content-Type" = "text/plain";
,显然情况并非如此。 -
有时您也可以使用
initWithContentsOfURL
方法之一的usedEncoding
选项:dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSStringEncoding encoding; NSError *error; NSString *string = [[NSString alloc] initWithContentsOfURL:url usedEncoding:&encoding error:&error]; if (error) NSLog(@"%s: initWithContentsOfURL error: %@", __FUNCTION__, error); if (string) NSLog(@"encoding = %d", encoding); });
但这报告了一个错误(再次表明,这可能根本不是字符串编码)。
简而言之,我建议您联系该网络服务的提供商,并询问他们有关格式的问题。但是看看十六进制转储,我不知道它的格式。粗略地看一下,它看起来像二进制数据,而不是任何字符串编码。