Open blumf opened 9 years ago
I think the solution approach you've suggested makes sense, and I don't have much to add for improvements other than: cur:getcoltypes support WCHAR, WTEXT, and WVARCHAR and possibly apply conversion functions in the application if column types come from these data types.
Check out the 9b6db204f6e403340c9494df090baec3f945acc5 ODBC_Unicode branch
Added utf8_fetch
and utf8_execute
functions.
Seems to work okay, although I don't have any DBs with NCHAR columns to test against (I mostly rescue data from the horrors of Access)
It's Windows only and needs some more tidying so a connection config can flip the default fetch/execute behaviour.
Uploaded a Lua 5.3 EXE with LuaSQL.ODBC DLL here: https://www.sendspace.com/file/vdgo6i md5sum ef259efe3f884806fd2fbafcce4f9ef1 *lua53-luasql_odbc_test-20150813.zip
I did try the .dll and see it is only designed for lua 5.3. We are still on lua 5.1. Any chance recompiling for Lua 5.1 for testing?
From: blumf [mailto:notifications@github.com] Sent: Thursday, August 13, 2015 8:11 AM To: keplerproject/luasql Cc: Beauregard, Mark Subject: Re: [luasql] [ODBC] NCHAR, WCHAR, Unicode Support (#36)
Uploaded a Lua 5.3 EXE with LuaSQL.ODBC DLL here: https://www.sendspace.com/file/vdgo6i md5sum ef259efe3f884806fd2fbafcce4f9ef1 *lua53-luasql_odbc_test-20150813.zip
— Reply to this email directly or view it on GitHubhttps://github.com/keplerproject/luasql/issues/36#issuecomment-130645105.
Okay, but it's likely that there'll be issues caused by differences in compiler used to build this and whatever you're using. You'd be better off just trying with the Lua EXE packaged in the zips and doing some basic tests there.
https://www.sendspace.com/file/pgya1n md5sum d2611c7f58b916bca54f90f209c22365 *lua51-luasql_odbc_test-20150813.zip
This is a common issue with the LuaSQL.ODBC driver, so I'm folding several tickets into this one.
Problem
The ODBC driver only supports local codepage text, running into Unicode text, such as NCHAR columns, doesn't work.
Fetching uses
SQLGetData
withSQL_C_CHAR
type, Executing usesSQLPrepare
rather thanSQLPrepareW
So, just mod the code to use the WCHAR types? Well... apart from the overhead of transliterating all the text, that has two issues:
Proposed Solution
MultiByteToWideChar
etc. functions for thisutf8_execute
andutf8_fetch
that support the WCHAR data. Also addlocal_execute/fetch
functions that just link to the existing ones.execute
andfetch
functions.Comment, etc. appreciated...