When working with content that is to be placed in EditLive! for XML it must be ensured that the relevant content is URL encoded before it is used with EditLive! for XML. Content is required to be URL encoded so that it can be used with the JavaScript used to instantiate EditLive! for XML.
It is recommended that when URL encoding content that this operation be performed on the server side through the use of the appropriate server side scripting function. It is possible to use the JavaScript escape or encodeURI functions however this is not recommended as these functions are not certain to provide correct URL encoding across all browsers.
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.
JavaScript has two URL encoding functions available; escape and encodeURI. The functionality of these two functions is browser dependant.
Although it is recommended that a server-side URL encoding function is used, in cases where client-side JavaScript must be used the encodeURI function should be used. The encodeURI function will encode content as UTF-8 characters.
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! for XML.
When implementing an EditLive! for XML integration with ColdFusion the URL encoding function which should be used is URLEncodedFormat. This function can be used in the following way:
When encoding content for use with EditLive! for XML that contains international characters it may be necessary to specify a character set for use with the server-side encoding method. For more information on which character set to use please consult your programming language reference. 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 charactering encoding method with EditLive! for XML are:
A square symbol appears on entering text. This symbol means the current character encoding 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. For example, a Document's character set has been defined as UTF-8. The Body of the document is set using the encode Java function in a JSP page, using the ISO2022JP encoding method. Because symbols created by the ISO2022JP encoding method are not supported by UTF-8, encoding errors will occur.
The methods available to change the character encoding method used by EditLive! for XML are depicted in Using Different Character Sets with EditLive! for XML.
Content which is to be added to EditLive! for XML should be URL encoded. The methods listed above can be used to URL encode content with several popular scripting languages. The JavaScript encodeURI function can also be used, however, this is not recommended as the encoding provided by this function does not comply with URL encoding in all browsers.
Copyright 2001-2005 Ephox Corporation. All Rights Reserved.