Url decoding

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Url decoding

Carlo Bertoldi-2
Hello again,
  I believe this is a quite common problem, but I couldn't find an
answer to my problem.
I'd like to URL encode/decode strings.
Encoding: edoc_lib:escape_uri("hello hello"). Perfect, but how can I go
back to the original string now?
Is it possible to do it without using external libs, as those found in
Yaws, or ibrowse? or I'll have to include one of those in my project?

Cheers,
  Carlo

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Url decoding

Loïc Hoguin
On 07/01/2011 11:10 AM, Carlo Bertoldi wrote:
> Hello again,
>   I believe this is a quite common problem, but I couldn't find an
> answer to my problem.
> I'd like to URL encode/decode strings.
> Encoding: edoc_lib:escape_uri("hello hello"). Perfect, but how can I go
> back to the original string now?
> Is it possible to do it without using external libs, as those found in
> Yaws, or ibrowse? or I'll have to include one of those in my project?

You could use ex_uri as a rebar dependency if you're using rebar:
    https://github.com/extend/ex_uri

--
Loïc Hoguin
Dev:Extend
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Url decoding

Chandru-4
In reply to this post by Carlo Bertoldi-2
On 1 July 2011 10:10, Carlo Bertoldi <[hidden email]> wrote:
Hello again,
 I believe this is a quite common problem, but I couldn't find an answer to my problem.
I'd like to URL encode/decode strings.
Encoding: edoc_lib:escape_uri("hello hello"). Perfect, but how can I go back to the original string now?
Is it possible to do it without using external libs, as those found in Yaws, or ibrowse? or I'll have to include one of those in my project?


The http_uri module which is part of inets is probably what you need.

cheers
Chandru


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Url decoding

Carlo Bertoldi-2
On 01/07/2011 14:17, Chandru wrote:

> On 1 July 2011 10:10, Carlo Bertoldi <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hello again,
>      I believe this is a quite common problem, but I couldn't find an
>     answer to my problem.
>     I'd like to URL encode/decode strings.
>     Encoding: edoc_lib:escape_uri("hello hello"). Perfect, but how can
>     I go back to the original string now?
>     Is it possible to do it without using external libs, as those
>     found in Yaws, or ibrowse? or I'll have to include one of those in
>     my project?
>
>
> The http_uri module which is part of inets is probably what you need.
>
> cheers
> Chandru
>
Hi Chandru, I looked into http_uri module, but it only exports the parse
function:

http_uri:parse("http://try.com/ciao%20ciao").
{http,[],"prova.com",80,"/ciao%20ciao",[]}

This doesn't solve my problem.

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Url decoding

Chandru-4
On 1 July 2011 13:23, Carlo Bertoldi <[hidden email]> wrote:
On 01/07/2011 14:17, Chandru wrote:

On 1 July 2011 10:10, Carlo Bertoldi <[hidden email] <mailto:[hidden email]>> wrote:

   Hello again,
    I believe this is a quite common problem, but I couldn't find an
   answer to my problem.
   I'd like to URL encode/decode strings.
   Encoding: edoc_lib:escape_uri("hello hello"). Perfect, but how can
   I go back to the original string now?
   Is it possible to do it without using external libs, as those
   found in Yaws, or ibrowse? or I'll have to include one of those in
   my project?


The http_uri module which is part of inets is probably what you need.

cheers
Chandru

Hi Chandru, I looked into http_uri module, but it only exports the parse function:

http_uri:parse("http://try.com/ciao%20ciao").
{http,[],"prova.com",80,"/ciao%20ciao",[]}

This doesn't solve my problem.

 
I thought you wanted to URL encode and decode strings. So are the encode and decode functions in that module not sufficient?

8> edoc_lib:escape_uri("hello hello").
"hello%20hello"

9> http_uri:decode(v(-1)).
"hello hello"

Chandru


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Url decoding

Carlo Bertoldi-2
On 01/07/2011 14:32, Chandru wrote:

>
> I thought you wanted to URL encode and decode strings. So are the
> encode and decode functions in that module not sufficient?
>
> 8> edoc_lib:escape_uri("hello hello").
> "hello%20hello"
>
> 9> http_uri:decode(v(-1)).
> "hello hello"
>
> Chandru
>
>
That's exactly what I'm looking for. I got it, I'm using R14A, but that
functions has been introduced in later versions.
Many thanks,
  Carlo

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Url decoding

Loïc Hoguin
In reply to this post by Chandru-4
> I thought you wanted to URL encode and decode strings. So are the encode
> and decode functions in that module not sufficient?
>
> 8> edoc_lib:escape_uri("hello hello").
> "hello%20hello"
>
> 9> http_uri:decode(v(-1)).
> "hello hello"

Note that while those functions are there, they are AFAIK not publicly
documented and could change or be removed at any time in the future.

--
Loïc Hoguin
Dev:Extend
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions