Changeset 699

Show
Ignore:
Timestamp:
09/06/07 14:23:07 (3 years ago)
Author:
astrange
Message:

If we guess one of latin1/2 for a file and it's invalid, try the other one. Refs #172.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Subtitles/SubUtilities.m

    r698 r699  
    128128        res = [[[NSString alloc] initWithData:data encoding:enc] autorelease]; 
    129129         
    130         if (!res) Codecprintf(NULL,"Failed to load file as guessed encoding %s.\n",[enc_str UTF8String]); 
     130        if (!res) { 
     131                if (latin2) { 
     132                        Codecprintf(NULL,"Encoding %s failed, retrying.\n",[enc_str UTF8String]); 
     133                        enc = (enc == NSWindowsCP1252StringEncoding) ? NSWindowsCP1250StringEncoding : NSWindowsCP1252StringEncoding; 
     134                        res = [[[NSString alloc] initWithData:data encoding:enc] autorelease]; 
     135                        if (!res) Codecprintf(NULL,"Both of latin1/2 failed.\n",[enc_str UTF8String]); 
     136                } else Codecprintf(NULL,"Failed to load file as guessed encoding %s.\n",[enc_str UTF8String]); 
     137        } 
    131138        [ud release]; 
    132139