From 35b8b4a488ac3e1a20a3d7dc489e35b773c897f3 Mon Sep 17 00:00:00 2001 From: Michael Heins Date: Mon, 29 May 2017 07:45:30 -0600 Subject: Add capability export and copy blobs as hex, if "Display Binary Data as Hex" is selected. --- Source/SPCopyTable.m | 7 ++++++- Source/SPTableContent.m | 12 +++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'Source') diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m index ed7b1d71..f2ad878f 100644 --- a/Source/SPCopyTable.m +++ b/Source/SPCopyTable.m @@ -197,7 +197,12 @@ static const NSInteger kBlobAsImageFile = 4; [result appendFormat:@"%@\t", NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields")]; else if ([cellData isKindOfClass:[NSData class]]) { if(withBlobHandling == kBlobInclude) { - NSString *displayString = [[NSString alloc] initWithData:cellData encoding:[mySQLConnection stringEncoding]]; + BOOL hexBlobs = [prefs boolForKey:SPDisplayBinaryDataAsHex]; + NSString *displayString; + if (hexBlobs) + displayString = [[NSString alloc] initWithFormat:@"0x%@", [cellData dataToHexString]]; + else + displayString = [[NSString alloc] initWithData:cellData encoding:[mySQLConnection stringEncoding]]; if (!displayString) displayString = [[NSString alloc] initWithData:cellData encoding:NSASCIIStringEncoding]; if (displayString) { [result appendFormat:@"%@\t", displayString]; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 4e3ee245..e2895e15 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -2382,6 +2382,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [currentResult addObject:[NSArray arrayWithArray:tempRow]]; + BOOL hexBlobs = [prefs boolForKey: SPDisplayBinaryDataAsHex]; // Add rows for (i = 0; i < [self numberOfRowsInTableView:tableContentView]; i++) { @@ -2440,7 +2441,16 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [[image TIFFRepresentationUsingCompression:NSTIFFCompressionJPEG factor:0.01f] base64Encoding]]]; } else { - [tempRow addObject:hide ? @"<BLOB>" : [o stringRepresentationUsingEncoding:[mySQLConnection stringEncoding]]]; + NSString *str; + if (hide) + str = @"<BLOB>"; + else if (hexBlobs) { + str = [NSString stringWithFormat: @"0x%@", [o dataToHexString]]; + } + else { + str = [o stringRepresentationUsingEncoding:[mySQLConnection stringEncoding]]; + } + [tempRow addObject: str]; } if(image) [image release]; -- cgit v1.2.3