Re: [erlang-questions] Sending String with Unicode Currency Symbols (like ₡) from erlang to C language NIF (Native Implemented functions)

Saurabh Narula reachsaurabhnarula@REDACTED
Fri Jun 4 11:39:22 CEST 2010


thank you bob for your reply, is there any other alternative than
sending Binary to NIF?

Robert,

My string has an xml which I intent to parse in C NIF and give it back
to erlang program. I make ERL_NIF_TERMS in C function and give them
back to erlang, I would like to have the format as string only. Or do
u have suggestions for any other format for the kind of operation I am
doing?

Thank you.
Saurabh


On Thu, Jun 3, 2010 at 10:45 PM, Bob Ippolito <bob@REDACTED> wrote:
> On Thu, Jun 3, 2010 at 10:02 AM, Saurabh Narula
> <reachsaurabhnarula@REDACTED> wrote:
>> Hello Everyone,
>>
>> i am trying to send erlang string from erlang program to the NIF
>> (Native Implemented functions) written in C language.
>>
>> While sending the string from erlang I have an option of specifying
>> the encoding. The functions that help me achieve this are
>>
>> ERL_NIF_TERM enif_make_string(ErlNifEnv* env, const char* string,
>> ErlNifCharEncoding encoding)
>> int enif_get_string(ErlNifEnv* env, ERL_NIF_TERM list, char* buf,
>> unsigned size, ErlNifCharEncoding encode)
>>
>> The only supported encoding is currently ERL_NIF_LATIN1 for
>> iso-latin-1 (8-bit ascii), and while sending it back to the erlang I
>> can specify the encoding as ERL_NIF_LATIN1, which is the only option
>> right now.
>>
>> My issue is that my string contains Unicode currency symbols like ₡,
>> as the encoding currently only supports ERL_NIF_LATIN1, there is no
>> way the NIF library can understand unicode currency symbols. Does
>> anybody has any workaround for this?
>
> You could use a UTF-8 encoded binary instead of a list.
>
> -bob
>


More information about the erlang-questions mailing list