Ok now I'm really confused an I can see why a using Char pointers should work, but when i make that change the the julia object being editted (and passed back and forth between julia and c) get s messed up: all the strings are random characters.
I have no idea why. The code is a (possible) beginning to an alternative JSON library for julia using ujson4c, code is here: https://github.com/samuelcolvin/uJSON.jl/blob/master/ujson.jl On Thursday, 15 May 2014 01:05:20 UTC+1, Steven G. Johnson wrote: > > > > On Wednesday, May 14, 2014 7:57:49 PM UTC-4, Samuel Colvin wrote: > >> function get_key(key_::Ptr{Int32}, key_length_::Ptr{Cint}) >> key_length = unsafe_load(key_length_) >> UTF32String(pointer_to_array(key_, int64(key_length), false)) >> end >> > > Change it to Ptr{Char} (Char is 4 bytes) instead of Ptr{Int32}, in order > to save yourself from making a copy of the data. > > Beware that this code may not be portable, if the C library you are using > employs the wchar_t type. If you want it to work on Windows, too, you may > need to deal with UTF16 on that system. (You could have two versions of > the function, depending on sizeof(Cwchar_t).) >