[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

re: [MacPerl] URL encoding



"John Springer" <john@digitalmx.com> writes:
} I'm trying to do URL encoding in a script, just like the browser does
} when it sends a query.
} I'm using :
}         $newchar='%'.hex(unpack("C",$char));
} to encode (which is not correct).
} I tried just hex($char) but that isn't right either.
} 
} I use:
}         s/%(\w\w)/chr(hex($1))/
} to decode (which I think is correct)
} 
} What is the correct encoding statement?  Also, do you know where I can
} find a list of what characters need to be encoded, besides & and %?

For these tasks, you should use URI::Escape in libwww-perl-5. Not only
do the authors know what needs to be escaped, they provide you with
simple to use routines so you don't have to know.  (Of course, if you
want to know what and how, you can always look inside.)  Mac ready
versions of libwww-perl-5 are available on my Web site,
<http://mors.gsfc.nasa.gov/>.

The other worry is that the ISO-whatever character set that's the
defined standard for HTML is not the same as the standard Mac character
set, so unless you're using an ISO font, you may have to translate
depending on your application.

} --
} 
} 
} -->John Springer
}         Still the Penultimate Mac bigot.
}       <http://www.digitalmx.com>
} 
} 
} 
} 
} 
---
--------
Paul J. Schinder
NASA Goddard Space Flight Center,
Code 693, Greenbelt, MD 20771 USA
schinder@pjstoaster.pg.md.us