Hi,

I have one of those types generated from a C struct with Clang.jl that 
turns a stack variable into a loooong list of members (for example (but I 
have longer ones))

https://github.com/joa-quim/GMT.jl/blob/master/src/libgmt_h.jl#L1246

(an in interlude: isn't yet any better way of representing a C "char 
str[256];"?)

when executed I get (example)

julia> hdr.x_units
GMT.Array_80_Uint8(0x6c,0x6f,0x6e,0x67,0x69,0x74,0x75,0x64,0x65,0x20,0x5b,
0x64,0x65,0x67,0x72,0x65,0x65,0x73,0x5f,0x65,0x61,0x73,0x74,0x5d,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00)

but I need to transform it into a string. After some suffering I came out 
with this solution

julia> join([Char(hdr.x_units.(n)) for n=1:sizeof(hdr.x_units)])
"longitude 
[degrees_east]\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"

well, it works but it's kind or ugly. Is there a better way of achieving 
this? Namely, how could I avoid creating a string with all of those \0's? I 
know I can remove them after, but what about not copying them on first 
place?

Thanks

Reply via email to