I need to get value from Julia Char datatype into C.
As I understand Char is implemented here and comment says:
Char
is a 32-bitAbstractChar
type that is the default representation of characters in Julia.Char
is the type used for character literals like'x'
and it is also the element type ofString
.
I have not found something like jl_unbox_char
, so I thought to use jl_string_ptr
. However it always prints c\
.
Here’s my code:
#include <julia.h>
int main(int argc, char *argv[])
{
char* str = malloc(sizeof(char) * 1024);
jl_init();
//jl_value_t *var = jl_eval_string("\"abc\""); //works
jl_value_t *var = jl_eval_string("'a'"); // does not work
if (jl_is_string(var)) {
str = jl_string_ptr(var);
} else if (jl_isa(var, jl_char_type)) {
str = jl_string_ptr(var);
}
jl_atexit_hook(0);
printf("%s", str);
return 0;
}
}
I’m interested how can I retrieve a Char value?