Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project









FUNCTION:  URL.escapeString

URL.escapeString(string)
 
The URL.escapeString function replaces all special characters in the given string (including a URL string) with the appropriate hexadecimal escape sequences and returns the modified string. The modified string (URL) is said to be escaped.
 
The companion URL.unescapeString function replaces all hexadecimal escape sequences with the appropriate special characters.
 
A hexadecimal escape sequence is composed of a mandatory percent sign followed immediately by the two-digit hexadecimal number (i.e., %2A). There are sixteen hexadecimal numbers: 1 2 3 4 5 6 7 8 9 0 A B C D E F (or a b c d e f)
 
Here is a list of special characters that can be escaped for a URL.
Please refer to: RFC2396 Uniform Resource Identifiers (URI): Generic Syntax.
Character Escape Sequence
control key see footnote 1
blank space %20
; %3B
/ %2F
? %3F
@ %40
& %26
= %3D
+ %2B
$ %24
, %2C
( see footnote 2
) see footnote 2
| %7C
\ %5C
^ %5E
[ %5B
] %5D
' %27
< %3C
> %3E
# %23
% %25
* %22
1. A URL cannot contain control characters.
2. The ( and ) were not escaped by the Nokia simulator.
 
The mandatory String parameter can be any string of characters in which you desire to replace all special characters with a hexadecimal escape sequence. This string can also be a URL.
 
Code for EscapeStringExample.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>

<card id="card1">
   <p>
   escapeString example
   </p>
   <do type="accept">
      <go href="EscapeStringExample.wmls#findescapestring()" />
   </do>
</card>

<card id="card2">
<p>
   original string = $(original)
   <br />
   escape string = $(escape)
</p>
</card>

</wml>

 
Code for EscapeStringExample.wmls
extern function findescapestring()
{
   var str = Dialogs.prompt("Enter string or URL", "");
   var esc = URL.escapeString(str);
   WMLBrowser.setVar("original", str);
   WMLBrowser.setVar("escape", esc);
   WMLBrowser.go("EscapeStringExample.wml#card2");
};

 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information