Skip to content

Commit

Permalink
Fixed unicode string length not being interpreted right by SQLite
Browse files Browse the repository at this point in the history
  • Loading branch information
adriencanterot committed Sep 28, 2016
1 parent f23d43b commit de7be4c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/SQLite/SQLite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ extension SQLite {
}

public func bind(_ value: String) throws {
let strlen = Int32(value.characters.count)
let strlen = Int32(value.utf8CString.count)
if sqlite3_bind_text(pointer, nextBindPosition, value, strlen, SQLITE_TRANSIENT) != SQLITE_OK {
throw SQLiteError.bind(database.errorMessage)
}
Expand All @@ -231,7 +231,7 @@ extension SQLite {
try bind(value ? 1 : 0)
}

//binds a null value, useful for inserting new rows without having to put an id

public func null() throws {
if sqlite3_bind_null(pointer, nextBindPosition) != SQLITE_OK {
throw SQLiteError.bind(database.errorMessage)
Expand Down

0 comments on commit de7be4c

Please sign in to comment.