Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accented characters with luasql-odbc #133

Open
lodumont opened this issue Oct 15, 2021 · 0 comments
Open

Accented characters with luasql-odbc #133

lodumont opened this issue Oct 15, 2021 · 0 comments

Comments

@lodumont
Copy link

lodumont commented Oct 15, 2021

I am trying to retrieve data from a Filemaker database containing accented letters (such as é or è, with UTF 8 encoding) using luasql-odbc. For example, in the following code, I am trying to get a location name (here "Tréboul"), but the accented character takes two bytes and the last letter of the string is truncated.

driver = require "luasql.odbc"
env = driver.odbc()
cnn = env:connect("DB", "user", "pwd")
sql = "SELECT col1 FROM table WHERE col2 = 'xxx'"
stmt = cnn:execute(sql)
row = stmt:fetch({}, "a")

print(row.col1)
> Trébou

string.byte(row.col1, 1, -1)
> 84	114	195	169	98	111	117

As you can see the "é" letters is here composed of two bytes (195 and 169) and the final "l" is missing.

Here is what my odbc.ini file looks like (I'm using unixodbc):

[ODBC Data Sources]
DB = FileMaker ODBC

[DB]
Driver                 = /Library/ODBC/FileMaker ODBC.bundle/Contents/MacOS/fmodbc.so
Description            = DB
Server                 = localhost
CertificateFailureType = Warning
Database               = DB
UseLongVarchar         = 
AutoDetectEncoding     = 
WideAPI                = Yes
UnicodeTextTypes       = Yes
MultiByteEncoding      = UTF-8
QueryLog_On            = 
QueryLogTime           = 
QueryLogFile           = 
Charset                = UTF-8

I'm accessing the same database through ODBC with R (RODBC package) and I have no issue with these characters, so I thought this could come from luasql. Any idea what might solve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant