Skip to content

Commit

Permalink
use utf8 encoding in exqlite_open nif
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Rychlewski authored and Greg Rychlewski committed Feb 16, 2024
1 parent 4d1b518 commit 6dd1416
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion c_src/sqlite3_nif.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ exqlite_open(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
return enif_make_badarg(env);
}

size = enif_get_string(env, argv[0], filename, MAX_PATHNAME, ERL_NIF_LATIN1);
size = enif_get_string(env, argv[0], filename, MAX_PATHNAME, ERL_NIF_UTF8);
if (size <= 0) {
return make_error_tuple(env, "invalid_filename");
}
Expand Down
10 changes: 10 additions & 0 deletions test/exqlite/connection_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ defmodule Exqlite.ConnectionTest do
assert state.db
end

test "connects to a file with an accented character" do
path = Temp.path!(prefix: "databasé")
{:ok, state} = Connection.connect(database: path)

assert state.path == path
assert state.db

File.rm(path)
end

test "fails to write a file from URL with mode=ro" do
path = Temp.path!()

Expand Down

0 comments on commit 6dd1416

Please sign in to comment.