From 546f93177ba556bf6aa47699200bb7f417596a44 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Wed, 11 Apr 2007 18:26:38 +0000 Subject: [PATCH] better handle non-UTF8 error messages --- macosx/Torrent.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 8cc2ad2be..4b239102c 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -955,7 +955,17 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 - (NSString *) errorMessage { - return [self isError] ? [NSString stringWithUTF8String: fStat->errorString] : @""; + if (![self isError]) + return @""; + + #warning localize string after release + NSString * error; + if (!(error = [NSString stringWithUTF8String: fStat->errorString]) + && !(error = [NSString stringWithCString: fStat->errorString encoding: NSISOLatin1StringEncoding])) + error = @""; + //error = NSLocalizedString(@"(unreadable error)", "Torrent -> error string unreadable"); + + return error; } - (BOOL) justFinished