Re: Question: how to do URL-encoding in ECLiPSe

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Thu 21 Mar 2002 04:29:36 PM GMT
Message-ID: <3C9A0A70.5A953B9F@icparc.ic.ac.uk>
"J.R. van Ossenbruggen" wrote:
> 
> I have a bunch of prolog strings that I want to use as URLs, but they
> contains whitespace and other characters that are illegal in URLs.  So
> I need to replace these chars (e.g. %20 for space).  Any hint how this
> could be conveniently done in Eclipse (other than to recurse over the
> strings char by char and do a manual translate)?


No nice shortcut, I'm afraid :-(
Here is some code that's used in lib(document):

htmlify_string(In, Out) :-
	string_list(In, InList),
	htmlify_list(InList, OutList),
	string_list(Out, OutList).

htmlify_list([], []).
htmlify_list([C|Cs], HtmlCs) :-
	htmlify(C, HtmlCs, HtmlCs0),
	htmlify_list(Cs, HtmlCs0).

htmlify(0'>, [0'&,0'g,0't,0';|Cs], Cs) :- !.
htmlify(0'<, [0'&,0'l,0't,0';|Cs], Cs) :- !.
htmlify(0'&, [0'&,0'a,0'm,0'p,0';|Cs], Cs) :- !.
htmlify(C, [C|Cs], Cs).



-- 
 Joachim Schimpf              /             phone: +44 20 7594 8187
 IC-Parc, Imperial College   /            mailto:J.Schimpf@ic.ac.uk
 London SW7 2AZ, UK         /    http://www.icparc.ic.ac.uk/eclipse
Received on Thu Mar 21 16:29:51 2002

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:13 PM GMT GMT