URL Encoding

When encoding a String, the following rules apply:

    * The alphanumeric characters "a" through "z", "A" through "Z" 
      and "0" through "9" remain the same.
    * The special characters ".", "-", "*", and "_" remain the same.
    * The space character " " is converted into a plus sign "+".
    * All other characters are unsafe and are first converted into one or more
      bytes using some encoding scheme. Then each byte is represented by the
      3-character string "%xy", where xy is the two-digit hexadecimal
      representation of the byte. The recommended encoding scheme to use is
      UTF-8. However, for compatibility reasons, if an encoding is not specified,
      then the default encoding of the platform is used. 

For example using UTF-8 as the encoding scheme the string "The string @foo-bar"
would get converted to "The+string+%C3%BC%40foo-bar" because in UTF-8 the character
 is encoded as two bytes C3 (hex) and BC (hex), and the character @ is encoded
as one byte 40 (hex).

---from java.net.URLEncoder javadoc


UTF-8

UTF-8 encoding form: The Unicode encoding form which assigns each Unicode
scalar value to an unsigned byte sequence of one to four bytes in length, as
specified in Table 3-5.

 - In UTF-8, the code point sequence <004D, 0430, 4E8C, 10302> is represented
as <4D D0 B0 E4 BA 8C F0 90 8C 82>, where <4D> corresponds to U+004D, <D0 B0>
corresponds to U+0430, <E4 BA 8C> corresponds to U+4E8C, and <F0 90 8C 82>
corresponds to U+10302.

 - Any UTF-8 byte sequence that does not match the patterns listed in Table 3-6
is illformed.

 - Before the Unicode Standard, Version 3.1, the problematic  non-shortest form
byte sequences in UTF-8 were those where BMP characters could be represented in
more than one way. These sequences are ill-formed, because they are not allowed
by Table 3-6.

 - Because surrogate code points are not Unicode scalar values, any UTF-8 byte
sequence that would otherwise map to code points D800..DFFF is ill-formed.

Table 3-5 specifies the bit distribution for the UTF-8 encoding form, showing
the ranges of Unicode scalar values corresponding to one-, two-, three-, and
four-byte sequences. For a discussion of the difference in the formulation of
UTF-8 in ISO/IEC 10646, see Section C.3, UCS Transformation Formats.

Table 3-6 lists all of the byte sequences that are well-formed in UTF-8. A range
of byte values such as A0..BF indicates that any byte from A0 to BF (inclusive)
is well-formed in that position. Any byte value outside of the ranges listed is
ill-formed. For example:

 - The byte sequence <C0 AF> is ill-formed, because C0 is not well-formed in the
1st Byte  column.

Table 3-5. UTF-8 Bit Distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Scalar Value               1st Byte 2nd Byte 3rd Byte 4th Byte
--------------------------+--------+--------+--------+--------
00000000 0xxxxxxx          0xxxxxxx                           
00000yyy yyxxxxxx          110yyyyy 10xxxxxx                  
zzzzyyyy yyxxxxxx          1110zzzz 10yyyyyy 10xxxxxx         
000uuuuu zzzzyyyy yyxxxxxx 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx
--------------------------+--------+--------+--------+--------

 - The byte sequence <E0 9F 80> is ill-formed, because in the row where E0 is
wellformed as a first byte, 9F is not well-formed as a second byte.

 - The byte sequence <F4 80 83 92> is well-formed, because every byte in that
sequence matches a byte range in a row of the table (the last row).

As a consequence of the well-formedness conditions specified in Table 3-6,
the following byte values are disallowed in UTF-8: C0 C1, F5 FF.

Table 3-6. Well-Formed UTF-8 Byte Sequences
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code Points        1st Byte 2nd Byte 3rd Byte 4th Byte
------------------+--------+--------+--------+--------
U+0000..U+007F     00..7F                             
U+0080..U+07FF     C2..DF   80..BF                    
U+0800..U+0FFF     E0       A0..BF   80..BF           
U+1000..U+CFFF     E1..EC   80..BF   80..BF           
U+D000..U+D7FF     ED       80..9F   80..BF           
U+E000..U+FFFF     EE..EF   80..BF   80..BF           
U+10000..U+3FFFF   F0       90..BF   80..BF   80..BF  
U+40000..U+FFFFF   F1..F3   80..BF   80..BF   80..BF  
U+100000..U+10FFFF F4       80..8F   80..BF   80..BF  
------------------+--------+--------+--------+--------
  Cases where a trailing byte range is not 80..BF are
  in bold italic to draw attention to them. These occur
  only in the second byte of a sequence.

---from Unicode 4 specification