URL encoding/decoding with Python

url encoding a “raw” unicode doesn’t really make sense. What you need to do is .encode(“utf8″) first so you have a known byte encoding and then .quote() that. The output isn’t very pretty but it should be a correct uri encoding. >>> s = u’1234567890-/:;()$&@”.,?!\'[]{}#%^*+=_\|~<>\u20ac\xa3\xa5\u2022.,?!\” >>> urllib2.quote(s.encode(“utf8”)) ‘1234567890-/%3A%3B%28%29%24%26%40%22.%2C%3F%21%27%5B%5D%7B%7D%23%25%5E%2A%2B%3D_%5C%7C%7E%3C%3E%E2%82%AC%C2%A3%C2%A5%E2%80%A2.%2C%3F%21%27’ Remember that you will need to both … Read more

urlencoded Forward slash is breaking URL

Apache denies all URLs with %2F in the path part, for security reasons: scripts can’t normally (ie. without rewriting) tell the difference between %2F and / due to the PATH_INFO environment variable being automatically URL-decoded (which is stupid, but a long-standing part of the CGI specification so there’s nothing can be done about it). You … Read more

How to encode URL in Groovy?

You could use java.net.URLEncoder. In your example above, the brackets must be encoded too: def toEncode = “dehydrogenase (NADP+)” assert java.net.URLEncoder.encode(toEncode, “UTF-8”) == “dehydrogenase+%28NADP%2B%29” You could also add a method to string’s metaclass: String.metaClass.encodeURL = { java.net.URLEncoder.encode(delegate, “UTF-8”) } And simple call encodeURL() on any string: def toEncode = “dehydrogenase (NADP+)” assert toEncode.encodeURL() == “dehydrogenase+%28NADP%2B%29”

NameValueCollection to URL Query?

Simply calling ToString() on the NameValueCollection will return the name value pairs in a name1=value1&name2=value2 querystring ready format. Note that NameValueCollection types don’t actually support this and it’s misleading to suggest this, but the behavior works here due to the internal type that’s actually returned, as explained below. Thanks to @mjwills for pointing out that … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)