encodeURI / decodeURI / escape 와 unescape를 대채할 수 있는 훌륭한 함수
페이지 정보
작성자 서방님 댓글 0건 조회 90회 작성일 07-08-08 15:52본문
http://www.ephox.com/developers/editliveforjava/v40/html/articles_encoding.html
When working with content that is to be placed in EditLive! for Java it must be ensured that the relevant content is URL encoded before it is used with EditLive! for Java. Content is required to be URL encoded so that it can be used with the JavaScript used to instantiate EditLive! for Java.
It should be noted that when instantiating EditLive! for Java with the ASP, ASP .NET or J2EE SDKs the content placed in the Style, Document and Body properties is automatically URL encoded using the appropriate URL encoding method.
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:
Note
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 Java.
When implementing an EditLive! for Java 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 Java 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 this 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.
A <meta> element specifying the character encoding should also be added to the EditLive! for Java configuration file. The following is an example <meta> tag specifying the UTF-8 character set:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Content which is to be added to EditLive! for Java 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.
댓글목록
등록된 댓글이 없습니다.