Improve file encoding detection.

CQTexperiment
Jan Weiß 2019-10-19 18:17:34 +02:00
parent f94226bcf2
commit 105b0f26bb
3 changed files with 14 additions and 0 deletions

View File

@ -72,6 +72,10 @@
error = nil;
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) {
error = nil;
contents = [NSString stringWithContentsOfFile:filename encoding:NSWindowsCP1251StringEncoding error:&error];

View File

@ -83,6 +83,11 @@
error = nil;
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) {
DLog(@"Trying windows CP1251");
error = nil;

View File

@ -85,6 +85,11 @@
error = nil;
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) {
DLog(@"Trying windows CP1251");
error = nil;