Made playlist/cuesheet encoding a little more robust (Vasfed).

CQTexperiment
vspader 2007-10-20 15:08:06 +00:00
parent 2e44b9833e
commit 5ff84158cc
4 changed files with 54 additions and 7 deletions

View File

@ -98,8 +98,6 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
amountRead += [self convert:dest + amountRead amount:amount - amountRead]; amountRead += [self convert:dest + amountRead amount:amount - amountRead];
} }
NSLog(@"Amount read: %i/%i", amountRead, amount);
return amountRead; return amountRead;
} }

View File

@ -61,8 +61,24 @@
- (void)parseFile:(NSString *)filename - (void)parseFile:(NSString *)filename
{ {
NSStringEncoding encoding;
NSError *error = nil; NSError *error = nil;
NSString *contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error]; NSString *contents = [NSString stringWithContentsOfFile:filename usedEncoding:&encoding error:&error];
if (error) {
NSLog(@"Trying UTF8");
error = nil;
contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error];
}
if (error) {
NSLog(@"Trying windows CP1251");
error = nil;
contents = [NSString stringWithContentsOfFile:filename encoding:NSWindowsCP1251StringEncoding error:&error];
}
if (error) {
NSLog(@"Trying latin1");
error = nil;
contents = [NSString stringWithContentsOfFile:filename encoding:NSISOLatin1StringEncoding error:&error];
}
if (error || !contents) { if (error || !contents) {
NSLog(@"Could not open file...%@ %@ %@", filename, contents, error); NSLog(@"Could not open file...%@ %@ %@", filename, contents, error);
return; return;

View File

@ -68,11 +68,27 @@
NSString *filename = [url path]; NSString *filename = [url path];
NSStringEncoding encoding;
NSError *error = nil; NSError *error = nil;
NSString *contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error]; NSString *contents = [NSString stringWithContentsOfFile:filename usedEncoding:&encoding error:&error];
if (error) {
NSLog(@"Trying UTF8");
error = nil;
contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error];
}
if (error) {
NSLog(@"Trying windows CP1251");
error = nil;
contents = [NSString stringWithContentsOfFile:filename encoding:NSWindowsCP1251StringEncoding error:&error];
}
if (error) {
NSLog(@"Trying latin1");
error = nil;
contents = [NSString stringWithContentsOfFile:filename encoding:NSISOLatin1StringEncoding error:&error];
}
if (error || !contents) { if (error || !contents) {
NSLog(@"Could not open file...%@ %@", contents, error); NSLog(@"Could not open file...%@ %@ %@", filename, contents, error);
return NO; return nil;
} }
NSString *entry; NSString *entry;

View File

@ -70,9 +70,26 @@
NSString *filename = [url path]; NSString *filename = [url path];
NSStringEncoding encoding;
NSError *error; NSError *error;
NSString *contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error]; NSString *contents = [NSString stringWithContentsOfFile:filename usedEncoding:&encoding error:&error];
if (error) {
NSLog(@"Trying UTF8");
error = nil;
contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error];
}
if (error) {
NSLog(@"Trying windows CP1251");
error = nil;
contents = [NSString stringWithContentsOfFile:filename encoding:NSWindowsCP1251StringEncoding error:&error];
}
if (error) {
NSLog(@"Trying latin1");
error = nil;
contents = [NSString stringWithContentsOfFile:filename encoding:NSISOLatin1StringEncoding error:&error];
}
if (error || !contents) { if (error || !contents) {
NSLog(@"Could not open file...%@ %@ %@", filename, contents, error);
return nil; return nil;
} }