Difference between revisions of "Ns urldecode"

From AOLserver Wiki
Jump to navigation Jump to search
(imported from WiKit id 694)
 
 
Line 22: Line 22:
 
     http://www.aolserver.com/
 
     http://www.aolserver.com/
  
    % set data [[ns_urlencode [format %c 0xe9]]]    ;# 0xe9 is the iso8859-1 for lowercase accented 'e'
+
The character é lowercase 'e' accent is represented by the byte e9 in iso8859-1 but in utf-8 by the two bytes c3 and a9.
    %c3%a9
 
 
      
 
      
     % string length [[ns_urldecode -charset utf-8 $data]]
+
     % ns_urldecode -charset iso8859-1 %e9
     1
+
    % é
 +
    % ns_urldecode -charset utf-8 %c3%a9
 +
     % é
  
     % string length [[ns_urldecode -charset iso8859-1 $data]]
+
Using the wrong charset may lead to errors. If one (two byte) utf-8 character was decoded using iso8859-1 it would result in two incorrect characters.
     2
+
 
 +
     % ns_urldecode -charset iso8859-1 %c3%a9
 +
     % é
  
 
'''SEE ALSO'''
 
'''SEE ALSO'''

Latest revision as of 10:49, 9 September 2007

Man page: http://aolserver.com/docs/tcl/ns_urldecode.html


NAME

ns_urldecode - URL decoding

SYNOPSIS

ns_urldecode ?-charset charset? data

DESCRIPTION

This command decodes a string according to the rules for URL encoding defined in RFC 1738, Uniform Resource Locators (URL). Essentially, each non-alphanumeric byte is converted to its hexadecimal representation, prepended with a percent sign.
The optional -charset charset parameter defines the character set of the encoded string. If not specified, the default is "utf-8".

EXAMPLES

   % ns_urldecode http%3a%2f%2fwww%2eaolserver%2ecom%2f
   http://www.aolserver.com/

The character é lowercase 'e' accent is represented by the byte e9 in iso8859-1 but in utf-8 by the two bytes c3 and a9.

   % ns_urldecode -charset iso8859-1 %e9
   % é
   % ns_urldecode -charset utf-8 %c3%a9
   % é

Using the wrong charset may lead to errors. If one (two byte) utf-8 character was decoded using iso8859-1 it would result in two incorrect characters.

   % ns_urldecode -charset iso8859-1 %c3%a9
   % é

SEE ALSO

ns_urlencode

Category Documentation - Category Core Tcl API