Re: [chicagoboss] how get unicode string from Req:query_param(name) ?

45 views
Skip to first unread message

Konstantin Nikiforov

unread,
Nov 28, 2012, 9:15:40 AM11/28/12
to chica...@googlegroups.com
> io:format for query "тест" =
> [209,130,208,181,209,129,209,130]
> How i can convert it to unicode list?

Different representations of multibyte encodings may be generated by:

1. Bin = list_to_binary([209,130,208,181,209,129,209,130]) - byte
string like <<209,130,208,181,209,129,209,130>>, ready for
sending to others programs/clients, storing, etc.

2. unicode:characters_to_list(Bin) -> [1090,1077,1089,1090].
A list of chars. Every char is represented using one integer.


В Wed, 28 Nov 2012 00:47:56 -0800 (PST)
guyvernk <gl...@guyvernk.com> пишет:

> Hello.
> Please help with this thing.
> JavaScript on client side send data from form to controller via GET
> method. I get query value from textbox
>
> var query = $(this).val();
> >
>
> And send to controller
>
> client.request('search', {'q':query}, function(result)
> > {...}
> >
>
> But on controller side i get 2-byte-encoding string.
>
> search('GET',[]) ->
> > Query = Req:query_param("q"),
> > io:format("~w~n",[Query]),
> > {output,vk_lib:get_songs([Query])}.
> >
>
> io:format for query "тест" =
> [209,130,208,181,209,129,209,130]
> How i can convert it to unicode list?
>

Reply all
Reply to author
Forward
0 new messages