Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

converting file names to UTF-8 when needed

  • Loading branch information...
commit 746adcde7fe4b04bcfe848e2bd494026ac5bfc78 1 parent f79833c
Aaron Patterson authored
Showing with 11 additions and 6 deletions.
  1. +7 −0 ext/sqlite3/database.c
  2. +4 −6 test/test_encoding.rb
7 ext/sqlite3/database.c
View
@@ -58,6 +58,13 @@ static VALUE initialize(int argc, VALUE *argv, VALUE self)
if(Qtrue == rb_hash_aref(opts, ID2SYM(rb_intern("utf16")))) {
status = sqlite3_open16(StringValuePtr(file), &ctx->db);
} else {
+
+#ifdef HAVE_RUBY_ENCODING_H
+ if(!UTF8_P(file)) {
+ file = rb_str_export_to_enc(file, rb_utf8_encoding());
+ }
+#endif
+
status = sqlite3_open_v2(
StringValuePtr(file),
&ctx->db,
10 test/test_encoding.rb
View
@@ -23,12 +23,10 @@ def test_blob_is_binary
assert_equal str, string.force_encoding('UTF-8')
end
- #def test_db_with_eucjp
- # #db = SQLite3::Database.new(':memory:'.encode('EUC-JP'))
- # db = SQLite3::Database.new(':memory:')
- # assert_equal(Encoding.find('UTF-8'), db.encoding)
- # p db.execute('select * from sqlite_master')
- #end
+ def test_db_with_eucjp
+ db = SQLite3::Database.new(':memory:'.encode('EUC-JP'))
+ assert_equal(Encoding.find('UTF-8'), db.encoding)
+ end
def test_db_with_utf16
db = SQLite3::Database.new(':memory:'.encode('UTF-16LE'))
Please sign in to comment.
Something went wrong with that request. Please try again.