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

UTF16String API updates #57

Closed
stevengj opened this issue May 30, 2014 · 7 comments
Closed

UTF16String API updates #57

stevengj opened this issue May 30, 2014 · 7 comments

Comments

@stevengj
Copy link

When JuliaLang/julia#7016 or similar is merged, it looks like your usage of UTF16String will break, as we discussed. You will probably want to use the utf16(...) constructor instead of UTF16String(...), or use the latter only if your data is already NUL terminated.

@jiahao
Copy link

jiahao commented Aug 6, 2014

I think I just ran into this.

In [1]:

using ODBC
In [2]:

listdrivers()
Out[2]:
0x2 Array{String,2}
In [3]:

listdsns()
Out[3]:
1x2 Array{String,2}:
 "mimic2"  "/usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so"
In [4]:

db = ODBC.connect("mimic2")
ODBC Connection Object
Out[4]:
----------------------
Connection Data Source: mimic2
mimic2 Connection Number: 1
Contains resultset? No
In [5]:

sql"SHOW DATABASES;"
ArgumentError("UTF16String data must be NULL-terminated")
while loading In[5], in expression starting on line 1

@quinnj
Copy link
Member

quinnj commented Aug 6, 2014

What's your versioninfo() @jiahao? I think I actually need to use WString to get this right.

@jiahao
Copy link

jiahao commented Aug 6, 2014

This is on julia.mit.edu:

In [6]:

versioninfo()
Julia Version 0.3.0-rc2+8
Commit 540dac0 (2014-08-06 16:02 UTC)
Platform Info:
  System: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E7- 8850  @ 2.00GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Nehalem)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

@dje
Copy link

dje commented Sep 5, 2014

Ran into this recently I believe:

julia> query("[some query that returns strings]")
ERROR: ArgumentError("UTF16String data must be NULL-terminated")
 in UTF16String at utf16.jl:5
 in ODBCCopy! at /Users/deden/.julia/v0.3/ODBC/src/backend.jl:144
 in ODBCFetchDataFrame at /Users/deden/.julia/v0.3/ODBC/src/backend.jl:196
 in query at /Users/deden/.julia/v0.3/ODBC/src/userfacing.jl:57
 in query at /Users/deden/.julia/v0.3/ODBC/src/userfacing.jl:43
versioninfo()
Julia Version 0.3.0
Commit 7681878* (2014-08-20 20:43 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin13.3.0)
  CPU: Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

@stevengj
Copy link
Author

stevengj commented Sep 6, 2014

It looks like ODBCClean(x::Array{Uint16},y,z) = UTF16String(x[1:z,y]) should be ODBCClean(x::Array{Uint16},y,z) = utf16(x[1:z,y]). You don't want wstring for Uint16 data, since wchar_t is a Uint32 on non-Windows platforms. However, you do want to use wstring if you have a C API that returns a wchar_t*, which should be Ptr{Cwchar_t} in Julia.

@killerswan
Copy link

Yeah, @stevengj, that worked for me. (Although I have other trouble after that, so YMMV.)

@quinnj
Copy link
Member

quinnj commented Oct 2, 2014

Closed by 7bc2267

@quinnj quinnj closed this as completed Oct 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants