0

I am trying to create an HTTP post request to a server. Part of the post parameters is a German movie title such as

 Cowboys & Aliens

or

 Das süße Leben

When the request gets posted by my browser the get posted as

 Cowboys+%26+Aliens

and

 Das+s%FC%DFe+Leben

I can't figure what type of encoding this is, and how to reproduce it in perl.

Can anyone help, please?

simone
  • 4,667
  • 4
  • 25
  • 47
  • 1
    It's called [URL encoding](http://en.m.wikipedia.org/wiki/Percent-encoding), and you can use [this](https://metacpan.org/pod/URI::Encode) module. That took me a whole 10 seconds of googling, next time try that first. – Biffen Jan 30 '15 at 07:24
  • @Biffen, sorry if I haven't made that clear but I've been using URI::Escape, and googled before - that's basic etiquette. I started from here http://stackoverflow.com/questions/13163937/decode-utf-8-url-in-perl but struggled to find a way that will encode/decode both strings consistently – simone Jan 30 '15 at 08:07
  • 1
    You should have mentioned that in the question. So what is your current problem, then? – Biffen Jan 30 '15 at 08:36
  • This is just a guess, but could there be an issue with how the second string is encoded within your Perl file? The character ß is encoded as 0xDF in ISO 88591-1 but as 0xC3 0x9F in UTF-8. Perhaps could the issue be that the bytes are escaped ie. to %C3%9F rather than the UTF-8 code-point being mapped back to ISO 8859-1 and represented as %DF? – clumb Jan 30 '15 at 13:05
  • The CPAN documentation Biffen linked to discusses that reserved characters e.g. '&' are only encoded if you explicitly ask them to be - is this a potential issue you need to look at? – clumb Jan 30 '15 at 13:10

1 Answers1

0

Use URI::Encode this will do the job for you.

Jens
  • 67,715
  • 15
  • 98
  • 113