1 | | |
2 | | |
3 | | |
4 | | |
5 | | |
6 | | |
7 | | |
8 | | |
9 | | |
10 | | |
11 | | |
12 | | |
13 | | |
14 | | |
15 | | |
16 | | |
17 | | |
18 | | |
19 | | |
20 | | |
21 | | |
22 | | |
23 | | |
24 | | |
25 | | |
26 | | |
27 | | |
28 | | |
29 | | |
30 | | |
31 | | |
32 | | |
33 | | |
34 | | |
35 | | |
36 | | |
37 | | |
38 | | |
39 | | |
40 | | |
41 | | |
42 | | |
43 | | |
44 | | |
45 | | |
46 | | |
47 | | |
48 | | |
49 | | |
50 | | |
51 | | |
52 | | |
53 | | |
54 | | |
55 | | |
56 | | |
57 | | |
58 | | |
59 | | |
60 | | |
61 | | |
62 | | |
63 | | |
64 | | |
| string *quote_from; | string *quote_to; | string *unquote_from; | string *unquote_to; | | void create() | { | quote_from=quote_to=unquote_from=unquote_to=({}); | for(int e=0;e<256;e++) | { | switch(e) | { | case 'a'..'z': | case 'A'..'Z': | case '0'..'9': | case 'å': case 'ä': case 'ö': | case 'Å': case 'Ä': case 'Ö': | case 'ü': case 'Ü': | case '!': | case '#': | case '$': | case '&': | case '/': | case '(': | case ')': | case '=': | case '-': | case '_': | case '+': | case '?': | case '~': | case '*': | case ',': | case '.': | case ';': | case ':': | break; | | default: | quote_from+=({sprintf("%c",e)}); | quote_to+=({sprintf("%%%02x",e)}); | } | unquote_from+=({sprintf("%%%02x",e)}); | unquote_to+=({sprintf("%c",e)}); | } | } | | string quote_param(string s) { return replace(s,quote_from,quote_to); } | string unquote_param(string s) { return replace(s,unquote_from,unquote_to); } | | string mktag(string tag, mapping params) | { | string ret="<"+tag; | foreach(indices(params),string i) | { | ret+=" "+quote_param(i); | | if(stringp(params[i])) | ret+="='"+quote_param(params[i])+"'"; | } | return ret+">"; | } | | |
|