-
Notifications
You must be signed in to change notification settings - Fork 77
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
[BUG] Characters' Encoding Problems #284
Comments
-3 is @markdirish I wonder if we need some sort of connection option which forces any character strings to be bound as SQL_C_WCHAR instead of SQL_C_CHAR, that way we can have a consistent encoding. Seems too many databases on Windows still using ANSI encoding for SQL_C_CHAR. |
I see now that the invalid buffer length message is getting printed for the 5th parm, which is the output string. Indeed, Of course, node-odbc always passes NULL/0 for the output buffer: https://github.com/markdirish/node-odbc/blob/55037241591beee343b3d9ce2e4f37ca8426255e/src/odbc.cpp#L416-L417 I'm guessing the discrepancy is being injected by the ODBC Driver Manager for some reason (though you'd think it would know better than passing in |
Might this be related to the fact that in my [ODBC 32 bit Data Sources]
DonneesSql=SQL Server (32 bit)
Winlassie=HFSQL (32 bit)
WinlassieSys=HFSQL (32 bit)
[DonneesSql]
Driver32=C:\WINDOWS\system32\SQLSRV32.dll
[Winlassie]
Driver32=C:\Program Files (x86)\Common Files\PC SOFT\27.0\ODBC\Win32x86\wd270hfo.dll
[WinlassieSys]
Driver32=C:\Program Files (x86)\Common Files\PC SOFT\27.0\ODBC\Win32x86\wd270hfo.dll
Even if I use the x64 version of the Windows ODBC Driver Manager, it creates only x32 entries in the EDIT: Winlassie is my DSN, and I tried to create both User and System DSNs in the Driver Manager, but both did not work.. |
May be it would be worth to mention: When using DBeaver to connect to the DB via ODBC, all characters are displayed correctly. And I even can export data (as csv for example), but when choosing an encoding of the data, the |
@kadler The problem was that the char encoding in the Database was set to CAST(CONVERT(column, 'WINDOWS1252', 'UTF8') AS VARCHAR(1024))
Thanks for the help ! |
@marbrex Glad you found a solution/workaround. I'm not sure all databases would have such conversion functions, however, so we'll probably still need to look in to a more universal solution. |
My system
odbc
Package Version: 2.4.4The bug
There is a problem with characters' encoding in the returned data. In fact, the text is in French and the letters with accents are not correctly displayed (é, è, ç, à, ù, ê, ô, etc..), and any of these non-ascii charcters results in this
"�"
. I've searched a lot for the reasons and possible solutions of this problem, tried everything I could, but with no success... The ODBC connection's encoding seems to be ANSI (must be ASCII), however the driver should support Unicode and be able to use the wide charset API, as it is stated on the official page of HFSQL installation procedure: https://doc.windev.com/en-US/?3044179What I tried to do
If I understood correctly, the encoding depends on the ODBC connections itself, and it can be either ANSI or Unicode. So, I tried to change the connection string, adding keywords such as
CCSID=1208
,Charset=UTF8
etc, to explicitly set the encoding to Unicode. But to my regret, these keywords are specific to the Database, and couldn't find any for HFSQL in particular...I tried these with different types/combinations of the connection string:
`DRIVER={${driver}};Server Name=${host};Server Port=${port};Database=${database};UID=${UID};PWD=${PWD}`
I also tried to debug with Windows' ODBC Driver Manager's Tracing function enabled. The log file seems to be ok, except 1 ODBC function: *
(*) The last message is in French, and says
IM006[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
. And even here in the log, it displays�
instead of characters !I don't know though why the connection string (3rd parameter of the function) is
"******\ 0"
and why its length (4th parameter) is equal to-3
.The
Invalid buffer length!
error should correspond to the following SQLDriverConnect SQLSTATE:But I don't understand this error..
I tried to define
'UNICODE'
indefines
of thebinding.gyp
file, but that did not help. P.S. I defined'DEBUG'
as well, but I do not get anynode-odbc
package's debug messages in the terminal when running my app withnpm start
(i'm using Express.js).Expected behavior
Correctly displayed characters in the query results.
pls help T_T
The text was updated successfully, but these errors were encountered: