Updated entity handling and URL encoding to match the latest spec version

Unicode characters are decoded from HTML entities while parsing and are
percent-encoded when written as URLs.