RE: [FO]: OB01 escape-uri

fn:escape-uri ("http://www.example.com/~bébé", true()) 
returns "http://www.example.com/%7Eb%E9b%E9" 

 
This one is wrong, unfortunately. The correct answer is (I believe) 

http%3A%2F%2Fwww.example.com%2F~b%C3%A9b%C3%A9

A better example is fn:escape-uri ("http://www.example.com/~bébé", false())

which returns

http://www.example.com/~b%C3%A9b%C3%A9

Note (a) that the characters are converted to UTF-8 octets, and then
hex-encoded, and (b) tilde is in the list of characters that aren't escaped,
whatever the setting of the second argument.

This also means that your sentence:

Each such character is replaced in the string by an escape sequence of the
form %HH, where HH is the hexadecimal representation of the octets used to
represent the character in UTF-8. 

would be better written as:

Each such character is replaced in the string by an escape sequence, which
is formed by encoding the character as a sequence of octets in UTF-8, and
then representing each of these octets in the form %HH, where HH is the
hexadecimal representation of the octet.


Michael Kay 

Received on Wednesday, 10 December 2003 14:46:31 UTC