Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Tests/FMDatabaseTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,17 @@ - (void)testUTF8Strings
XCTAssertFalse([self.db hadError], @"Shouldn't have any errors");
}

- (void)testNonUTF8Data
{
[self.db executeUpdate:@"create table utf8bug (a blob)"];
XCTAssertTrue(([self.db executeUpdate:@"insert into utf8bug (a) values (?)", [NSData dataWithBytes:"\xFF\xFF" length:4]]));

[self.db executeStatements:@"select * from utf8bug" withResultBlock:^int(NSDictionary *results) {
NSLog(@"%@", results);
return 0;
}];
}

- (void)testArgumentsInArray
{
[self.db executeUpdate:@"create table testOneHundredTwelvePointTwo (a text, b integer)"];
Expand Down
3 changes: 3 additions & 0 deletions src/fmdb/FMDatabase.m
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,9 @@ int FMDBExecuteBulkSQLCallback(void *theBlockAsVoid, int columns, char **values,
for (NSInteger i = 0; i < columns; i++) {
NSString *key = [NSString stringWithUTF8String:names[i]];
id value = values[i] ? [NSString stringWithUTF8String:values[i]] : [NSNull null];
if (value == nil) {
value = [NSString stringWithCString:values[i] encoding:NSASCIIStringEncoding];
}
[dictionary setObject:value forKey:key];
}

Expand Down