aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableContent.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/TableContent.m')
-rw-r--r--Source/TableContent.m92
1 files changed, 3 insertions, 89 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 3d723c1b..e6f0d085 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -890,7 +890,7 @@
else
[editTextView setString:@""];
- [hexTextView setString:[self dataToHex:editData]];
+ [hexTextView setString:[editData dataToFormattedHexString]];
// If the image cell now contains a valid image, select the image view
if (image) {
@@ -1125,7 +1125,7 @@
// Set the string contents and hex representation
if(contents)
[editTextView setString:contents];
- [hexTextView setString:[self dataToHex:editData]];
+ [hexTextView setString:[editData dataToFormattedHexString]];
[contents release];
editSheetWillBeInitialized = NO;
@@ -1169,92 +1169,6 @@
}
-- (NSString *)dataToHex:(NSData *)data
-/*
- returns the hex representation of the given data
- */
-{
- unsigned i;
- unsigned totalLength = [data length];
- int bytesPerLine = 16;
- NSMutableString *retVal = [NSMutableString string];
- char *nodisplay = "\t\n\r\f";
-
- // get the length of the longest location
- int longest = [(NSString *)[NSString stringWithFormat:@"%X", totalLength - ( totalLength % bytesPerLine )] length];
-
- for ( i = 0; i < totalLength; i += bytesPerLine ) {
- int j;
- NSMutableString *hex = [[NSMutableString alloc] initWithCapacity:(3 * bytesPerLine - 1)];
- NSMutableString *location = [[NSMutableString alloc] initWithCapacity:(longest + 2)];
- NSMutableString *chars = [[NSMutableString alloc] init];
- unsigned char *buffer;
- int buffLength = bytesPerLine;
-
- // add hex value of location
- [location appendString:[NSString stringWithFormat:@"%X", i]];
-
- // pad it
- while( longest > [location length] ) {
- [location insertString:@"0" atIndex:0];
- }
-
- // get the chars from the NSData obj
- if ( i + buffLength >= totalLength ) {
- buffLength = totalLength - i;
- }
- buffer = (unsigned char*) malloc( sizeof( unsigned char ) * buffLength );
- NSRange range = { i, buffLength };
- [data getBytes:buffer range:range];
-
- // build the hex string
- for ( j = 0; j < buffLength; j++ ) {
- unsigned char byte = *(buffer + j);
- if ( byte < 16 ) {
- [hex appendString:@"0"];
- }
- [hex appendString:[NSString stringWithFormat:@"%X", byte]];
- [hex appendString:@" "];
-
- // if the char is undisplayable, replace it with "."
- unsigned char current;
- int count = 0;
- while ( ( current = *(nodisplay + count++) ) > 0 ) {
- if ( current == byte ) {
- *(buffer + j) = '.';
- break;
- }
- }
- }
-
- // add padding to missing hex values.
- for ( j = 0; j < bytesPerLine - buffLength; j++ ) {
- [hex appendString:@" "];
- }
-
- // remove extra ghost characters
- [chars appendString:[NSString stringWithCString:(char *)buffer]];
- if ( [chars length] > bytesPerLine ) {
- [chars deleteCharactersInRange:NSMakeRange( bytesPerLine, [chars length] - bytesPerLine )];
- }
-
- // build line
- [retVal appendString:location];
- [retVal appendString:@" "];
- [retVal appendString:hex];
- [retVal appendString:@" "];
- [retVal appendString:chars];
- [retVal appendString:@"\n"];
-
- // clean up
- [hex release];
- [chars release];
- [location release];
- free( buffer );
- }
-
- return retVal;
-}
//getter methods
- (NSArray *)currentDataResult
@@ -2350,7 +2264,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
if ( [theValue isKindOfClass:[NSData class]] ) {
image = [[[NSImage alloc] initWithData:theValue] autorelease];
- [hexTextView setString:[self dataToHex:theValue]];
+ [hexTextView setString:[theValue dataToFormattedHexString]];
stringValue = [[NSString alloc] initWithData:theValue encoding:[mySQLConnection encoding]];
if (stringValue == nil)