Improve file encoding detection.
parent
f94226bcf2
commit
105b0f26bb
|
@ -72,6 +72,10 @@
|
||||||
error = nil;
|
error = nil;
|
||||||
contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error];
|
contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error];
|
||||||
}
|
}
|
||||||
|
if (error) {
|
||||||
|
error = nil;
|
||||||
|
contents = [NSString stringWithContentsOfFile:filename encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000) error:&error];
|
||||||
|
}
|
||||||
if (error) {
|
if (error) {
|
||||||
error = nil;
|
error = nil;
|
||||||
contents = [NSString stringWithContentsOfFile:filename encoding:NSWindowsCP1251StringEncoding error:&error];
|
contents = [NSString stringWithContentsOfFile:filename encoding:NSWindowsCP1251StringEncoding error:&error];
|
||||||
|
|
|
@ -83,6 +83,11 @@
|
||||||
error = nil;
|
error = nil;
|
||||||
contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error];
|
contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error];
|
||||||
}
|
}
|
||||||
|
if (error) {
|
||||||
|
DLog(@"Trying windows GB 18030 2000");
|
||||||
|
error = nil;
|
||||||
|
contents = [NSString stringWithContentsOfFile:filename encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000) error:&error];
|
||||||
|
}
|
||||||
if (error) {
|
if (error) {
|
||||||
DLog(@"Trying windows CP1251");
|
DLog(@"Trying windows CP1251");
|
||||||
error = nil;
|
error = nil;
|
||||||
|
|
|
@ -85,6 +85,11 @@
|
||||||
error = nil;
|
error = nil;
|
||||||
contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error];
|
contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error];
|
||||||
}
|
}
|
||||||
|
if (error) {
|
||||||
|
DLog(@"Trying windows GB 18030 2000");
|
||||||
|
error = nil;
|
||||||
|
contents = [NSString stringWithContentsOfFile:filename encoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000) error:&error];
|
||||||
|
}
|
||||||
if (error) {
|
if (error) {
|
||||||
DLog(@"Trying windows CP1251");
|
DLog(@"Trying windows CP1251");
|
||||||
error = nil;
|
error = nil;
|
||||||
|
|
Loading…
Reference in New Issue