On Aug 21, 2008, at 7:32 PM, James Howison wrote:
On Aug 21, 2008, at 9:16 PM, Maxwell, Adam R wrote:On 08/21/08 17:59, "James Howison" <[EMAIL PROTECTED]> wrote:On Aug 21, 2008, at 8:39 PM, Maxwell, Adam R wrote:On 08/21/08 14:38, "Christiaan Hofman" <[EMAIL PROTECTED]> wrote:It probably used Unicode, because that's tried before UTF-8. Shows my point that you can't just trust it only because it didn't fail.It only uses Unicode if the file has the appropriate BOM, and UTF-8 must not have that. James, what is the encoding of the document you dropped the file on? If it's Mac Roman or Latin 1, it's probably "succeeding" with that encoding and never tries UTF-8. Mac Roman is gapless so you'll always get something out of it.AFAICS it's utf-8 (ok, that's what TextMate reports and when opened with that encoding the ï character (umlaut-i) shows up fine.Okay, but what was the encoding of the .bib document you dropped this /on/? When you drop a file, BibDesk guesses encoding in this order: 1) encoding of /destination/ document 2) extended attribute com.apple.TextEncoding 3) check for BOM; if present, use UTF-16 (big or little-endian, as appropriate) 4) try default C string encoding (typically Mac Roman) 5) try ISO Latin 1 So if your document uses Mac Roman, you'll never get past the first condition.Sorry Adam, should have read more carefully :) It was ASCII. I confirmed that dropping it on a new bib, saved as UTF-8, meant that it was properly inserted.
Hmmm...yeah, that makes sense too, unfortunately, and I didn't think of it at the time. Sorry about that :(. If you can compile from source, try editing NSString_BDSKExtensions.m as follows:
- (NSString *)initWithContentsOfFile:(NSString *)path encoding: (NSStringEncoding)encoding guessEncoding:(BOOL)try;
{
if(self = [self init]){
NSData *data = [[NSData alloc] initWithContentsOfFile:path
options:NSMappedRead error:NULL];
NSString *string = nil;
// if we're guessing, try the reliable encodings first
if(try && dataHasUnicodeByteOrderMark(data) && encoding !=
NSUnicodeStringEncoding)
string = [[NSString alloc] initWithData:data
encoding:NSUnicodeStringEncoding];
if(try && nil == string && encoding != NSUTF8StringEncoding)
string = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
// read com.apple.TextEncoding on Leopard, or when reading a Tiger file saved on Leopard
if(try && nil == string) {
encoding = [[NSFileManager defaultManager]
appleStringEncodingAtPath:path error:NULL];
if (encoding > 0)
string = [[NSString alloc] initWithData:data
encoding:encoding];
}
// try the encoding passed as a parameter, if non-zero (zero
encoding is never valid)
if(nil == string && encoding > 0)
string = [[NSString alloc] initWithData:data
encoding:encoding];
// now we just try a few wild guesses
if(nil == string && try && encoding != [NSString
defaultCStringEncoding])
string = [[NSString alloc] initWithData:data encoding:
[NSString defaultCStringEncoding]];
if(nil == string && try && encoding !=
[BDSKStringEncodingManager defaultEncoding])
string = [[NSString alloc] initWithData:data encoding:
[BDSKStringEncodingManager defaultEncoding]];
// final fallback is Mac Roman (gapless)
if(nil == string && try && encoding !=
NSMacOSRomanStringEncoding)
string = [[NSString alloc] initWithData:data
encoding:NSMacOSRomanStringEncoding];
[data release];
[self release];
self = string;
}
return self;
}
This changes the heuristic to check for UTF-16, UTF-8,
com.apple.TextEncoding, then the supplied encoding parameter, and
finally to use a WAG.
-- Adam
smime.p7s
Description: S/MIME cryptographic signature
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ Bibdesk-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/bibdesk-users
