Reputation: 3061
Are there any well-known PL functions/libraries for extending a PostgreSQL (9.4.1) database with URL encoding (also known as percent encoding) capabilities?
Here's an example of the intended functionality:
International donor day: give blood for a good cause!
International%20donor%20day%3A%20give%20blood%20for%20a%20good%20cause%21
I guess an alternative would be to roll out my own implementation, since AFAIK there is currently no built-in way of doing this.
Upvotes: 0
Views: 3909
Reputation: 324771
This is trivial to do in an external PL,e.g.
CREATE LANGUAGE plpythonu;
CREATE OR REPLACE FUNCTION urlescape(original text) RETURNS text LANGUAGE plpythonu AS $$
import urllib
return urllib.quote(original);
$$
IMMUTABLE STRICT;
Upvotes: 3