Decode just as Javascript"s decodeURIComponent() does.

Decode just as Javascript"s decodeURIComponent() does.

am 27.07.2007 07:20:06 von wanliyou

--===============1049541030==
Content-Type: multipart/alternative;
boundary="----=_Part_863_18769011.1185513606378"

------=_Part_863_18769011.1185513606378
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,
I wanna decode string just as avascript's function ecodeURIComponent()
does, but I can't find any module may help after I searched in CPAN (because
of the installation problem)
What I can find is the function unescape() which is useless to me.
Who knows how to solve?
Thanks in advance.

------=_Part_863_18769011.1185513606378
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,

    I wanna decode string just as avascript's function ecodeURIComponent() does, but I can't find any module may help after I searched in CPAN (because of the installation problem)

    What I can find is the function unescape() which is useless to me.

    Who knows how to solve?

    Thanks in advance.


 


------=_Part_863_18769011.1185513606378--

--===============1049541030==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1049541030==--

RE: Decode just as Javascript"s decodeURIComponent() does.

am 27.07.2007 13:32:08 von Brian Raven

From: activeperl-bounces@listserv.ActiveState.com
[mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of
Question
Sent: 27 July 2007 06:20
To: Active Perl
Subject: Decode just as Javascript's decodeURIComponent() does.

> Hi,
> I wanna decode string just as avascript's function
ecodeURIComponent() does, but I can't find any module =

> may help after I searched in CPAN (because of the installation
problem)

Installation problem? Installing what? All you need to search CPAN is an
internet connection and a browser that you can point at
http://search.cpan.org

> What I can find is the function unescape() which is useless to me.

Really? I can't find an unescape function at all. 'perldoc -f unescape'
says it doesn't exist.

> Who knows how to solve?

If you have installed Activestate Perl, you should already have
URI::Escape on you hard disk, which seems to do something similar to
what Google tells me that decodeURIComponent does.

HTH

-- =

Brian Raven =


==================== =====3D=
================
Atos Euronext Market Solutions Disclaimer
==================== =====3D=
================

The information contained in this e-mail is confidential and solely for the=
intended addressee(s). Unauthorised reproduction, disclosure, modification=
, and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediat=
ely and delete it from your system. The views expressed in this message do =
not necessarily reflect those of Atos Euronext Market Solutions.

Atos Euronext Market Solutions Limited - Registered in England & Wales with=
registration no. 3962327. Registered office address at 25 Bank Street Lon=
don E14 5NQ United Kingdom. =

Atos Euronext Market Solutions SAS - Registered in France with registration=
no. 425 100 294. Registered office address at 6/8 Boulevard Haussmann 750=
09 Paris France.

L'information contenue dans cet e-mail est confidentielle et uniquement des=
tinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. Tou=
te copie, publication ou diffusion de cet email est interdite. Si cet e-mai=
l vous parvient par erreur, nous vous prions de bien vouloir prevenir l'exp=
editeur immediatement et d'effacer le e-mail et annexes jointes de votre sy=
steme. Le contenu de ce message electronique ne represente pas necessaireme=
nt la position ou le point de vue d'Atos Euronext Market Solutions.
Atos Euronext Market Solutions Limited Soci=E9t=E9 de droit anglais, enregi=
str=E9e au Royaume Uni sous le num=E9ro 3962327, dont le si=E8ge social se =
situe 25 Bank Street E14 5NQ Londres Royaume Uni.

Atos Euronext Market Solutions SAS, soci=E9t=E9 par actions simplifi=E9e, e=
nregistr=E9 au registre dui commerce et des soci=E9t=E9s sous le num=E9ro 4=
25 100 294 RCS Paris et dont le si=E8ge social se situe 6/8 Boulevard Hauss=
mann 75009 Paris France.
==================== =====3D=
================

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: Decode just as Javascript"s decodeURIComponent() does.

am 27.07.2007 14:55:14 von eroode

Look for URI::Encode, in your local configuration or on CPAN.


Eric

________________________________

From: activeperl-bounces@listserv.ActiveState.com
[mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of
Question
Sent: Friday, July 27, 2007 1:20 AM
To: Active Perl
Subject: Decode just as Javascript's decodeURIComponent() does.


Hi,
I wanna decode string just as avascript's function
ecodeURIComponent() does, but I can't find any module may help after I
searched in CPAN (because of the installation problem)
What I can find is the function unescape() which is useless to me.
Who knows how to solve?
Thanks in advance.



_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: Decode just as Javascript"s decodeURIComponent() does.

am 30.07.2007 04:39:07 von wanliyou

--===============0536142853==
Content-Type: multipart/alternative;
boundary="----=_Part_19413_17753822.1185763147312"

------=_Part_19413_17753822.1185763147312
Content-Type: text/plain; charset=ISO-2022-JP
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

To Brian:
That's uri_escape() function in the URI::Escape module, sorry for the
clerical error. :-)


To others:
I just found the escape & unescape in the URI::Escape module.
It seems escape & unescape are not recommended ones, also the
escape function does not work the same as encodeURIComponent does.
See the reference:

MSDN JScript Reference: The escape method returns a string value (in Unicode
format) that contains the contents of [the argument]. All spaces,
punctuation, accented characters, and any other non-ASCII characters are
replaced with %xx encoding, where xx is equivalent to the hexadecimal number
representing the character. For example, a space is returned as "%20."
Edge Core Javascript Guide: The escape and unescape functions let you encode
and decode strings. The escape function returns the hexadecimal encoding of
an argument in the ISO Latin character set. The unescape function returns
the ASCII string for the specified hexadecimal encoding value.

MSDN JScript Reference: The encodeURI method returns an encoded URI. If you
pass the result to decodeURI, the original string is returned. The encodeURI
method does not encode the following characters: ":", "/", ";", and "?". Use
encodeURIComponent to encode these characters. Edge Core Javascript Guide:
Encodes a Uniform Resource Identifier (URI) by replacing each instance of
certain characters by one, two, or three escape sequences representing the
UTF-8 encoding of the character

MSDN JScript Reference: The encodeURIComponent method returns an encoded
URI. If you pass the result to decodeURIComponent, the original string is
returned. Because the encodeURIComponent method encodes all characters, be
careful if the string represents a path such as
/folder1/folder2/default.html. The slash characters will be encoded and will
not be valid if sent as a request to a web server. Use the encodeURI method
if the string contains more than a single URI component. Mozilla Developer
Core Javascript Guide$B!'(B Encodes a Uniform Resource Identifier (URI) component
by replacing each instance of certain characters by one, two, or three
escape sequences representing the UTF-8 encoding of the character.


So, I think
escape will not encode *69 characters : *$B!$(B+$B!$(B-$B!$(B.$B!$(B/$B!$(B@$B!$(B_$B!$ (B0-9$B!$(Ba-z$B!$(BA-Z*
encodeURI will not encode *82 **characters :
!$B!$(B#$B!$(B$$B!$(B&$B!$(B'$B!$(B($B!$(B)$B!$ (B*$B!$(B+$B!$(B,$B!$(B-$B!$(B.$B!$(B/$B!$(B:$ B!$(B;$B!$(B=$B!$(B?$B!$(B@$B!$(B_$B!$(B~$B!$(B 0-9$B!$(Ba-z$B!$(BA-Z*
encodeURIComponent will not encode *71 characters : !$B!$(B
'$B!$(B($B!$(B)$B!$(B*$B!$(B-$B!$(B.$B!$(B_$B!$ (B~$B!$(B0-9$B!$(Ba-z$B!$(BA-Z*
**
They are not the same.

Now, my solution is make a js file with a encoded string as STDIN, decoded
string as STDOUT which will be called by $string = `cscript
decode.js$string`;and cmd window will flash. That's a stupid design in
my mind. Oops...







--
>: ~

------=_Part_19413_17753822.1185763147312
Content-Type: text/html; charset=ISO-2022-JP
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

To Brian:

    That's uri_escape() function in the URI::Escape module, sorry for the clerical error. :-)

 

 

To others:

     I just found the escape & unescape in the URI::Escape module.

     It seems escape & unescape are not recommended ones, also the escape function does not work the same as encodeURIComponent does.

    See the reference:

 

MSDN JScript Reference: The escape method returns a string value (in Unicode format) that contains the contents of [the argument]. All spaces, punctuation, accented characters, and any other non-ASCII characters are replaced with %xx encoding, where xx is equivalent to the hexadecimal number representing the character. For example, a space is returned as "%20."

Edge Core Javascript Guide: The escape and unescape functions let you encode and decode strings. The escape function returns the hexadecimal encoding of an argument in the ISO Latin character set. The unescape function returns the ASCII string for the specified hexadecimal encoding value.

 

MSDN JScript Reference: The encodeURI method returns an encoded URI. If you pass the result to decodeURI, the original string is returned. The encodeURI method does not encode the following characters: ":", "/", ";", and "?". Use encodeURIComponent to encode these characters. Edge Core Javascript Guide: Encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, or three escape sequences representing the UTF-8 encoding of the character

 

MSDN JScript Reference: The encodeURIComponent method returns an encoded URI. If you pass the result to decodeURIComponent, the original string is returned. Because the encodeURIComponent method encodes all characters, be careful if the string represents a path such as /folder1/folder2/default.html. The slash characters will be encoded and will not be valid if sent as a request to a web server. Use the encodeURI method if the string contains more than a single URI component. Mozilla Developer Core Javascript Guide$B!'(B Encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, or three escape sequences representing the UTF-8 encoding of the character.

 

 

So, I think

escape will not encode 69 characters : *$B!$(B+$B!$(B-$B!$(B.$B!$(B/$B!$(B@$B!$(B_$B!$ (B0-9$B!$(Ba-z$B!$(BA-Z

encodeURI will not encode 82 characters : !$B!$(B#$B!$(B$$B!$(B&$B!$(B' $B!$(B($B!$(B)$B!$(B*$B!$(B+$B!$(B,$B!$(B-$B!$ (B.$B!$(B/$B!$(B:$B!$(B;$B!$(B=$B!$(B?$B!$(B@$B !$(B_$B!$(B~$B!$(B0-9$B!$(Ba-z$B!$(BA-Z

encodeURIComponent will not encode 71 characters : !$B!$(B ' $B!$(B($B!$(B)$B!$(B*$B!$(B-$B!$(B.$B!$(B_$B!$ (B~$B!$(B0-9$B!$(Ba-z$B!$(BA-Z

 

They are not the same.

 

Now, my solution is make a js file with a encoded string as STDIN, decoded string as STDOUT which will be called by $string = `cscript decode.js $string`;
and cmd window will flash. That's a stupid design in my mind. Oops...


 



 


--
>: ~

------=_Part_19413_17753822.1185763147312--

--===============0536142853==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0536142853==--

Re: Decode just as Javascript"s decodeURIComponent() does.

am 30.07.2007 08:48:34 von Bill Luebkert

Question wrote:
> To Brian:
> That's uri_escape() function in the URI::Escape module, sorry for
> the clerical error. :-)
>
> To others:
> I just found the escape & unescape in the URI::Escape module.
> It seems escape & unescape are not recommended ones, also the
> escape function does not work the same as encodeURIComponent does.

Not recommended by whom ?

> See the reference:
> ...
> They are not the same.

So what ? It doesn't matter too much if you encode some extra stuff
since whatever you encode will get decoded properly. I'd use the one
that encodes the most characters and you should be safe. That appears
to be 'uri_escape' in your synopsis. Whatever one you use to escape,
the result can be unescaped the same - you could even just use an RE:

my ($uri = $string) =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;

So I would just pick uri_escape or encodeURI or even an RE - it doesn't
matter much. Example RE to encode:

$str =~ s/([^A-Z0-9\/_@.!~*'()+-])/sprintf "%%%02X", ord $1/eig;

> Now, my solution is make a js file with a encoded string as STDIN,
> decoded string as STDOUT which will be called by $string = `cscript
> decode.js $string`; and cmd window will flash. That's a stupid design in
> my mind. Oops...

I agree. :)


_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: Decode just as Javascript"s decodeURIComponent() does.

am 30.07.2007 09:22:13 von wanliyou

--===============1492032851==
Content-Type: multipart/alternative;
boundary="----=_Part_20569_13082323.1185780133437"

------=_Part_20569_13082323.1185780133437
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 7/30/07, Bill Luebkert wrote:
>
> Question wrote:
> > To Brian:
> > That's uri_escape() function in the URI::Escape module, sorry for
> > the clerical error. :-)
> >
> > To others:
> > I just found the escape & unescape in the URI::Escape module.
> > It seems escape & unescape are not recommended ones, also the
> > escape function does not work the same as encodeURIComponent does.
>
> Not recommended by whom ?


Not recommended by W3C, escape && unescape are abandoned since Javascript
1.5.

> See the reference:
> > ...
> > They are not the same.
>
> So what ? It doesn't matter too much if you encode some extra stuff
> since whatever you encode will get decoded properly. I'd use the one
> that encodes the most characters and you should be safe. That appears
> to be 'uri_escape' in your synopsis. Whatever one you use to escape,
> the result can be unescaped the same - you could even just use an RE:
>
> my ($uri = $string) =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
>
> So I would just pick uri_escape or encodeURI or even an RE - it doesn't
> matter much. Example RE to encode:
>
> $str =~ s/([^A-Z0-9\/_@.!~*'()+-])/sprintf"%%%02X", ord $1/eig;


Thanks for your regexp, encode process been done in the browser. In my perl
code, I just need a decode function correspondingly.

> Now, my solution is make a js file with a encoded string as STDIN,
> > decoded string as STDOUT which will be called by $string = `cscript
> > decode.js $string`; and cmd window will flash. That's a stupid design in
> > my mind. Oops...
>
> I agree. :)
>
>
>


--
>: ~

------=_Part_20569_13082323.1185780133437
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline



On 7/30/07, Bill Luebkert <> wrote:
Question wrote:
> To Brian:
>     That's uri_escape() function in the URI::Escape module, sorry for

> the clerical error. :-)
>
> To others:
>      I just found the escape & unescape in the URI::Escape module.
>      It seems escape & unescape are not recommended ones, also the

> escape function does not work the same as encodeURIComponent does.

Not recommended by whom ?

 

Not recommended by W3C, escape && unescape are abandoned since Javascript 1.5.


>     See the reference:
> ...
> They are not the same.

So what ?  It doesn't matter too much if you encode some extra stuff

since whatever you encode will get decoded properly.  I'd use the one
that encodes the most characters and you should be safe.  That appears
to be 'uri_escape' in your synopsis.  Whatever one you use to escape,

the result can be unescaped the same - you could even just use an RE:

       my ($uri = $string) =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;

So I would just pick uri_escape or encodeURI or even an RE - it doesn't

matter much.  Example RE to encode:

       $str =~ s/([^A-Z0-9\/_@.!~*'()+-])/sprintf"%%%02X", ord $1/eig;

 

Thanks for your regexp, encode process been done in the browser. In my perl code, I just need a decode function correspondingly.


> Now, my solution is make a js file with a encoded string as STDIN,
> decoded string as STDOUT which will be called by $string = `cscript

> decode.js $string`; and cmd window will flash. That's a stupid design in
> my mind. Oops...

I agree.  :)





--
>: ~

------=_Part_20569_13082323.1185780133437--

--===============1492032851==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1492032851==--

RE: Decode just as Javascript"s decodeURIComponent() does.

am 30.07.2007 15:15:39 von eroode

On Sunday, July 29, 2007 10:39 PM, Question wrote:

> That's uri_escape() function in the URI::Escape module, sorry for
> the clerical error. :-)

> To others:
> I just found the escape & unescape in the URI::Escape module.
> It seems escape & unescape are not recommended ones, also the
> escape function does not work the same as encodeURIComponent
> does. See the reference:

> MSDN JScript Reference: The escape method returns a string value (in
> Unicode format) that contains the contents of [the argument]. All
> spaces, punctuation, accented characters, and any other non-ASCII
> characters are replaced with %xx encoding, where xx is equivalent to
> the hexadecimal number representing the character. For example, a
> space is returned as "%20."

> Edge Core Javascript Guide: The escape and unescape functions let
> you encode and decode strings. The escape function returns the
> hexadecimal encoding of an argument in the ISO Latin character
> set. The unescape function returns the ASCII string for the
> specified hexadecimal encoding value.

> MSDN JScript Reference: The encodeURI method returns an encoded
> URI. If you pass the result to decodeURI, the original string is
> returned. The encodeURI method does not encode the following
> characters: ":", "/", ";", and "?". Use encodeURIComponent to encode
> these characters. Edge Core Javascript Guide: Encodes a Uniform
> Resource Identifier (URI) by replacing each instance of certain
> characters by one, two, or three escape sequences representing the
> UTF-8 encoding of the character

> MSDN JScript Reference: The encodeURIComponent method returns an
> encoded URI. If you pass the result to decodeURIComponent, the
> original string is returned. Because the encodeURIComponent method
> encodes all characters, be careful if the string represents a path
> such as /folder1/folder2/default.html. The slash characters will be
> encoded and will not be valid if sent as a request to a web
> server. Use the encodeURI method if the string contains more than a
> single URI component. Mozilla Developer Core Javascript Guide?
> Encodes a Uniform Resource Identifier (URI) component by replacing
> each instance of certain characters by one, two, or three escape
> sequences representing the UTF-8 encoding of the character.

> So, I think escape will not encode 69 characters :
> *?+?-?.?/?@?_?0-9?a-z?A-Z

> encodeURI will not encode 82 characters :
> !?#?$?&?'?(?)?*?+?,?-?.?/?:?;?=???@?_?~?0-9?a-z?A-Z

> encodeURIComponent will not encode 71 characters : !?
> '?(?)?*?-?.?_?~?0-9?a-z?A-Z

> They are not the same.

> Now, my solution is make a js file with a encoded string as STDIN,
> decoded string as STDOUT which will be called by $string = `cscript
> decode.js $string`; and cmd window will flash. That's a stupid
> design in my mind. Oops...


I don't see the problem.

The uri_escape function from URI::Encode lets you choose which
characters to encode, and it handles utf8 encoding. So you can make
it behave like any of the js functions you mention. What else could
you need?


Eric
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs