[erlang-questions] Conversion of string into Ascii values ??

Hynek Vychodil <>
Thu Feb 28 13:51:35 CET 2008


> term_to_binary("abc").
<<131,107,0,3,97,98,99>>

131 is erlang binary tag.
107 is short list contain only chars (STRING_EXT)
0, 3 is length of list
97, 98, 99 is "abc"

I thnik you should take it in message from erlang node.

2008/2/28 J Bhanot <>:

>
> Hi,
>
> I am bit confused in C node for this......beacuse when i send "abc" from
> Erlang node to C.....
>
> I have used all this to check the type.......where buff is the message
> from Erlang node i.e. "abc"
>
>  k = ERL_IS_INTEGER(buff);
>   fprintf(stderr, " intType %d\n\r", k);
>
>         k = ERL_IS_UNSIGNED_INTEGER(buff);
>   fprintf(stderr, " uintType %d\n\r", k);
>
>         k = ERL_IS_FLOAT(buff);
>   fprintf(stderr, " fltType %d\n\r", k);
>         k = ERL_IS_ATOM(buff);
>   fprintf(stderr, " atomType %d\n\r", k);
>         k = ERL_IS_PID(buff);
>   fprintf(stderr, " pidType %d\n\r", k);
>         k = ERL_IS_PORT(buff);
>   fprintf(stderr, " portType %d\n\r", k);
>         k = ERL_IS_REF(buff);
>   fprintf(stderr, " refType %d\n\r", k);
>         k = ERL_IS_TUPLE(buff);
>   fprintf(stderr, " tupType %d\n\r", k);
>         k = ERL_IS_BINARY(buff);
>   fprintf(stderr, " binType %d\n\r", k);
>         k = ERL_IS_LIST(buff);
>   fprintf(stderr, " listType %d\n\r", k);
>         k = ERL_IS_EMPTY_LIST(buff);
>   fprintf(stderr, " elistType %d\n\r", k);
>         k = ERL_IS_CONS(buff);
>   fprintf(stderr, " consType %d\n\r", k);
>
>
> Now, it gives true for int type ..............and hence I have to use
> erl_mk_int.....which gives me values in Ascii in C node...
>
> Is there a way in which I get abc in C node instead of Ascii values..
>
> Thanks,
> jb
>
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
--Hynek (Pichi) Vychodil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080228/639d4298/attachment.html>


More information about the erlang-questions mailing list