digital-fabric / extralite

Ruby on SQLite
http://www.rubydoc.info/gems/extralite
MIT License
255 stars 8 forks source link

String encoding #27

Closed gschlager closed 1 year ago

gschlager commented 1 year ago

Is it intentional that extralite always returns strings with a "ASCII-8BIT" encoding? I was trying to switch existing code from the sqlite3 gem to extralite and that's currently a blocker for me.

The following code snippet shows the difference in behavior between those two gems.

require "extralite"
require "sqlite3"

db = Extralite::Database.new("/tmp/extralite.db")
value = db.query_single_value("SELECT 'foo'")
puts "Extralite: #{value.encoding}"
db.close

db = SQLite3::Database.new("/tmp/sqlite3.db")
value = db.get_first_value("SELECT 'foo'")
puts "SQLite3: #{value.encoding}"
db.close

It outputs the following:

Extralite: ASCII-8BIT SQLite3: UTF-8

Shouldn't extralite use UTF-8 by default as well?