Client-side URL Encoding Functions
The following functions provide URL encoding for strings on the client-side. Where possible, it is recommended that a server-side URL encoding function be used as the exact behavior of these functions is browser dependant.
This may conflict with the Character Sets specified for use with EditLive!.
Server-side URL Encoding Functions
Most scripting languages provide a function to URL encode strings. The following section defines URL encoding functions which can be used with several common server side scripting languages.
The URL encoding function which can be using in ASP is Server.URLEncode. This can be used in the following manner:
The URL encoding function which can be used in ASP.NET is HttpUtility.UrlEncode. This class is part of the System.Web package. The function can be used in the following manner, with the correct "using" statement:
The URL encoding method which can be used in JSP and Java classes is the URLEncoder.encode() method. The URLEncoder class can be found in the java.net package. The function can be used in the following manner and the relevant import statements must be included:
When using the PHP URL encoding functions, it is important to use the rawurlencode function as opposed to the urlencode function. The function can be used in the following manner:
It is important to note that the urlencode function provides different functionality to the rawurlencode function. The urlencode function encodes spaces as + symbols which may cause errors with EditLive!.
When implementing an EditLive! integration with ColdFusion the URL encoding function which should be used is URLEncodedFormat. This function can be used in the following way:
Perl does not include a URL Encode function as part of the standard libraries; developers must write their own. This can be achieved through the use of regular expressions. The following code gives an example on how this may be achieved:
Encoding with International Characters
When encoding content for use with EditLive! that contains international characters it may be necessary to specify a character set for use with the server-side encoding method. Please consult your programming language reference for more information on how to specify a character set. It is recommended that UTF-8 character encoding is used in these circumstances, though other character encodings may also be used.
Symptoms of using an incorrect character encoding method with EditLive! are:
- The □ appears on entering text. This symbol means the current font set being used does not support the character entered.
- The symbol ? appears on entering text. This means character encoding has been corrupted due to an incorrect character encoding method.
A document's character set has been defined as UTF-8. The body of the document has been set using the URLEncoder.encode() Java function in a JSP page, with the ISO2022JP charset. Because symbols created by the ISO02022JP encoding method are not supported by UTF-8, encoding errors will occur.
The methods available to change the character encoding method used by EditLive! are depicted in the Specifying Character Set article.