From: superpollo on
hi.

is there a smarter way to do percent decoding (and encoding) other than
a mere succession of sed substitutions?

bye
From: Seebs on
On 2010-01-22, superpollo <utente(a)esempio.net> wrote:
> hi.
>
> is there a smarter way to do percent decoding (and encoding) other than
> a mere succession of sed substitutions?

What do you mean "percent decoding (and encoding)"? You want to convert
ratios to percentages? Values not allowed in URLs to ASCII hex codes?
printf format strings to output?

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: superpollo on
Seebs ha scritto:
> On 2010-01-22, superpollo <utente(a)esempio.net> wrote:
>> hi.
>>
>> is there a smarter way to do percent decoding (and encoding) other than
>> a mere succession of sed substitutions?
>
> What do you mean "percent decoding (and encoding)"? You want to convert
> ratios to percentages? Values not allowed in URLs to ASCII hex codes?
> printf format strings to output?
>
> -s

i mean:


http://en.wikipedia.org/wiki/Percent-encoding
From: Hallvard B Furuseth on
superpollo writes:
> is there a smarter way to do percent decoding (and encoding) other than
> a mere succession of sed substitutions?

I don't remember which characters need to be encoded, but for
illustration here is a version which encodes all but letters and
whitespace.

perl -wple 's/([^\w\s])/sprintf("%%%02X", ord($1))/eg'

man perlop and man perlfunc describes s//eg and sprintf.

--
Hallvard
From: Janis Papanagnou on
superpollo wrote:
> Seebs ha scritto:
>> On 2010-01-22, superpollo <utente(a)esempio.net> wrote:
>>> hi.
>>>
>>> is there a smarter way to do percent decoding (and encoding) other
>>> than a mere succession of sed substitutions?
>>
>> What do you mean "percent decoding (and encoding)"? You want to convert
>> ratios to percentages? Values not allowed in URLs to ASCII hex codes?
>> printf format strings to output?
>>
>> -s
>
> i mean:
>
>
> http://en.wikipedia.org/wiki/Percent-encoding

What Seebs probably meant:

http://catb.org/~esr/faqs/smart-questions.html


Janis