<!DOCTYPE html>
<html><head>
<meta charset="UTF-8">
</head><body>I tried<br><br>bin_is_7bit/1<br>bom_to_encoding/1<br>encoding_to_bom/1<br><br>and didn't try the ones starting with characters keyword as I had this doubt regarding them<br>that I have a binary not a character at hand already<br><br>But thank you for the reply<br><br>> On May 10, 2017 at 5:49 PM Attila Rajmund Nohl <attila.r.nohl@gmail.com> wrote:<br>> <br>> <br>> Hello!<br>> <br>> Have you actually tried any of them? I presume this is what you need:<br>> <br>> 5> B= <<97,0,109,0,97,0,110,0>>.<br>> <<97,0,109,0,97,0,110,0>><br>> 9> unicode:characters_to_list(B, {utf16, little}).<br>> "aman"<br>> <br>> <br>> 2017-05-10 13:36 GMT+02:00 Abhishek Ranjan <abhishek@blacklightsw.com>:<br>> > I had a look at the unicode library of erlang and it contained following<br>> > BIFs<br>> ><br>> > bin_is_7bit/1<br>> > bom_to_encoding/1<br>> > characters_to_binary/1<br>> > characters_to_binary/2<br>> > characters_to_binary/3<br>> > characters_to_binary_int/2<br>> > characters_to_list/1<br>> > characters_to_list/2<br>> > characters_to_list_int/2<br>> > encoding_to_bom/1<br>> > module_info/0<br>> > module_info/1<br>> ><br>> > But what I have is already a binary and I need it to convert into string,or<br>> > given the erlang's logic of storing string as a list of characters I need<br>> > binary to list converter but there isn't any as it looks like to me.<br>> ><br>> > Please share suggestions.<br>> ><br>> ><br>> >> On May 10, 2017 at 4:37 PM Hugo Mills <hugo@carfax.org.uk> wrote:<br>> >><br>> >><br>> >> On Wed, May 10, 2017 at 04:11:18PM +0530, Abhishek Ranjan wrote:<br>> >> > I have set up a chat application using ejabberd(built using erlang) and<br>> >> > Pidgin.<br>> >> ><br>> >> > I have witnessed a proceeding where when I print out a message sent by<br>> >> > the client to server on ejabberd it comes out as string<br>> >> ><br>> >> > For example,if I send a message as<br>> >> ><br>> >> > aman<br>> >> ><br>> >> > from the pidgin and print it inside the module containing ejabberd hook<br>> >> > as CustomMod.erl using<br>> >> ><br>> >> > ><br>> >> > > Bin=xmpp:get_text(Packet#message.body),<br>> >> > > Name=binary_to_list(Bin),<br>> >> > ><br>> >> > > ?INFO_MSG("The value of Name is ~p~n",[Name]),<br>> >> > ><br>> >> ><br>> >> > the output comes as "aman"<br>> >> ><br>> >> > but I have a simple erlang module also for login as login.erl and it<br>> >> > does not implement any ejabberd behavior, but is called from within<br>> >> > CustomMod.erl when I print this message out in this module it comes enclosed<br>> >> > within these << >> but are separated by 0's like<br>> >> ><br>> >> > aman becomes here as <<97,0,109,0,97,0,110,0>><br>> >><br>> >> That looks like little-endian UTF-16 to me. You probably need to do<br>> >> some Unicode conversion on your binary.<br>> >><br>> >> Hugo.<br>> >><br>> >> > which on doing binary_to_list(Variable) inside my login.erl I get-><br>> >> > [97,0,109,0,97,0,110,0]<br>> >> ><br>> >> > (where Variable is the value enclosed within <<>>)<br>> >> ><br>> >> > Can anyone tell me why is it happening and what is the way to get the<br>> >> > value aman in login.erl also?<br>> >> ><br>> >> ><br>> >> > Regards,<br>> >> ><br>> >> > Abhishek<br>> >><br>> >> > _______________________________________________<br>> >> > erlang-questions mailing list<br>> >> > erlang-questions@erlang.org<br>> >> > http://erlang.org/mailman/listinfo/erlang-questions<br>> >><br>> >><br>> >> --<br>> >> Hugo Mills | There are two hard problems in computer science:<br>> >> hugo@... carfax.org.uk | Cache invalidation, naming things, and off-by-one<br>> >> http://carfax.org.uk/ | errors.<br>> >> PGP: E2AB1DE4 |<br>> ><br>> > _______________________________________________<br>> > erlang-questions mailing list<br>> > erlang-questions@erlang.org<br>> > http://erlang.org/mailman/listinfo/erlang-questions<br>> ><br></body></html>