// Utilities for HTML manipulation. HTMLEncode[line] := { line =~ %s/&/&/g; line =~ %s//>/g; return line } // Decodes the hex-encoded parts of an argument. URLDecode[arg] := { return arg =~ %s/%([0-9a-fA-F]{2})/char[parseInt[$1, 16]]/ge } // Helper function to return a zero-padded hexadecimal number. hexpad[c] := { cc = hex[char[c]] if (length[cc] == 1) cc = "0$cc" return "%$cc" } // URL encode a part of a string to be used in a URL. The specification for // URLs (RFC 1738, Dec. '94) states "...Only alphanumerics [0-9a-zA-Z], the // special characters "$-_.+!*'()," and reserved characters used for // their reserved purposes may be used unencoded within a URL." URLEncode[str] := { return str =~ %s/([^0-9a-zA-Z\$\-\_\.\+\!\*\'\(\)\,])/hexpad[$1]/ge } // Make the tags for an HTML