Query and fragment encoding. Relates to #1.