Topic: CUEs with non-ansi encoding won't open

2007-10-17 23:09:40.551 Cog[2118] Could not open file.../Volumes/WEST;SERVER/Music/ethnic/_celtic/VA - Celtic Twilight vol.5(1999)/CDImage.cue (null) NSError "File “CDImage.cue” could not be opened using text encoding Unicode (UTF-8)." Domain=NSCocoaErrorDomain Code=261 UserInfo={
    NSFilePath = "/Volumes/WEST;SERVER/Music/ethnic/_celtic/VA - Celtic Twilight vol.5(1999)/CDImage.cue"; 
    NSStringEncoding = 4; 
}

- and so for every file containing non-unicode and non-ansi charsets (tried with cp1251 and something like latin1 (don't know exactly, supposed to be just latin but with diacritics))

Re: CUEs with non-ansi encoding won't open

Re: CUEs with non-ansi encoding won't open

Thanks, I'll look into it.

Re: CUEs with non-ansi encoding won't open

possible fix:

<...>
- (void)parseFile:(NSString *)filename
{
    NSError *error = nil;
    NSStringEncoding enc = nil;
    NSLog(@"Trying to open with encoding detection...");
    NSString *contents = [NSString stringWithContentsOfFile:filename usedEncoding:&enc error:&error];
    if (error) {
        NSLog(@"Trying to open as unicode...");
        error = nil;
        contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error];
        }
    if (error) {
        NSLog(@"Last hope: opening using cp1251...");
        error = nil;
        contents = [NSString stringWithContentsOfFile:filename encoding:NSWindowsCP1251StringEncoding error:&error]; //!!! constant used
        }
    if (error || !contents) {
        NSLog(@"Could not open file...%@ %@ %@", filename, contents, error);
        return;
    }
<...>

but this requires knowing system/user language and non-unicode encoding for this, easy way - make it tunable by user

PS. constants inside code could really be pain in the ass - in early days when programs were small and computers were big there're some accidents, for example once rocket was blasted due to unchanged constant...

Last edited by Vasfed (2007-10-18 05:35:33)

Re: CUEs with non-ansi encoding won't open

Ok, I've included your patch. Should be working as of r596.