UnicodeUrlEncode and UnicodeFormUrlEncode (Unicode functions): Difference between revisions

From m204wiki
Jump to navigation Jump to search
Line 15: Line 15:
<ul>
<ul>
<li>If an EBCDIC version of the UTF-8 encoded unicode string is needed, the UTF-8 encoded string should be converted back to unicode using <var>[[Utf8ToUnicode (String function)|Utf8ToUnicode]]</var> and then assigned to a string variable using either implicit Unicode to EBCDIC translation or doing it explicitly with <var>[[UnicodeToEbcdic (Unicode function)|UnicodeToEbcdic]]</var>. The conversion back to EBCDIC should require no [http://en.wikipedia.org/wiki/Character_entity_reference character entity encoding] since URL encoding only uses the most common ASCII characters.  This process is shown in the following [[#Examples|example]].
<li>If an EBCDIC version of the UTF-8 encoded unicode string is needed, the UTF-8 encoded string should be converted back to unicode using <var>[[Utf8ToUnicode (String function)|Utf8ToUnicode]]</var> and then assigned to a string variable using either implicit Unicode to EBCDIC translation or doing it explicitly with <var>[[UnicodeToEbcdic (Unicode function)|UnicodeToEbcdic]]</var>. The conversion back to EBCDIC should require no [http://en.wikipedia.org/wiki/Character_entity_reference character entity encoding] since URL encoding only uses the most common ASCII characters.  This process is shown in the following [[#Examples|example]].
<li>The difference between <var>UnicodeFormUrlEncode</var> and <var>UnicodeUrlEncode</var> is that <var>UnicodeFormUrlDecode</var> converts spaces to pluses (<code>+</code>) while <var>UnicodeUrlEncode</var> percent encodes spaces as <code>%20</code>. Typically form URL encoding is only used in HTML form posts when the form is posted using the x-www-form-urlencoded content type.
<li>The difference between <var>UnicodeFormUrlEncode</var> and <var>UnicodeUrlEncode</var> is that <var>UnicodeFormUrlDecode</var> converts spaces to pluses (<code>+</code>) while <var>UnicodeUrlEncode</var> percent encodes spaces as <code>%20</code>. Typically, form URL encoding is only used in HTML form posts when the form is posted using the x-www-form-urlencoded content type.
<li>URL encoding is mostly used in web applications or for encoding a URI, possibly in an XML namespace declaration.
<li>URL encoding is mostly used in web applications or for encoding a URI, possibly in an XML namespace declaration.
</ul>
</ul>

Revision as of 19:36, 22 August 2011

URL encode unicode characters (Unicode class)

[Introduced in Sirius Mods 7.9]

UnicodeUrlEncode and UnicodeFormUrlEncode URL encode or percent-encode a Unicode string.

Syntax

%string = unicode:UnicodeUrlEncode

%string = unicode:UnicodeFormUrlEncode

Syntax terms

%stringThe UTF-8 encoded string that results from URL or percent encoding unicode.
unicode The Unicode method object that is to be URL encoded.

Usage notes

  • If an EBCDIC version of the UTF-8 encoded unicode string is needed, the UTF-8 encoded string should be converted back to unicode using Utf8ToUnicode and then assigned to a string variable using either implicit Unicode to EBCDIC translation or doing it explicitly with UnicodeToEbcdic. The conversion back to EBCDIC should require no character entity encoding since URL encoding only uses the most common ASCII characters. This process is shown in the following example.
  • The difference between UnicodeFormUrlEncode and UnicodeUrlEncode is that UnicodeFormUrlDecode converts spaces to pluses (+) while UnicodeUrlEncode percent encodes spaces as %20. Typically, form URL encoding is only used in HTML form posts when the form is posted using the x-www-form-urlencoded content type.
  • URL encoding is mostly used in web applications or for encoding a URI, possibly in an XML namespace declaration.

Examples

The following example URL encodes a Unicode string and converts it to EBCDIC:

begin %ebcdic is longstring %unicode is unicode %unicode = 'I like apple &pi;. and eat it 4 &times; a day.':u %ebcdic = %unicode:unicodeUrlEncode:utf8ToUnicode printText {~} = {%ebcdic} end

The example output is:

%ebcdic = I%20like%20apple%20%CF%80.%20and%20eat%20it%204%20%C3%97%20a%20day.

See also