non ascii url parameter

4 views
Skip to first unread message

Franklin Brauning

unread,
Nov 14, 2016, 1:22:42 PM11/14/16
to Nitrogen Project / The Nitrogen Web Framework for Erlang
I'm getting errors when retrieving non ascii url parameters

for example: wf:q(id) or wf:q_pl([id]) when the url parameter id is "ají"

Now the current page parameter is encoded as id=aj%ED, right?
And when I want to retrieve this with wf:q(id), it fails with:

[{wf_convert,inner_to_list,
             [{incomplete,"aj",<<"í">>}],
             [{file,"src/lib/wf_convert.erl"},{line,58}]},
 {wf,'-q_pl/1-lc$^0/1-0-',1,[{file,"src/wf.erl"},{line,362}]},


Franklin Brauning

unread,
Nov 14, 2016, 2:06:59 PM11/14/16
to Nitrogen Project / The Nitrogen Web Framework for Erlang
The problem is triggered by unicode:characters_to_binary

The id is stored in redis as "aj\xed"  (it should display "ají")

In erl:

1> "aj\xed".
"ají"
2> unicode:characters_to_binary("aj\xed").
<<"ají"/utf8>>
3> unicode:characters_to_binary(<<"aj\xed">>).
{incomplete,<<"aj">>,<<"í">>}

More confusing to me is that "ají" when LANG=es_ES.utf8 is a list of length 3
but when LANG=es_ES the list is of length 4 and is valid utf encoded. For example,
python also emits the same 4 ints list. So what's that 3 length string?
Reply all
Reply to author
Forward
0 new messages