The entire `try` block should just be replaced with `querystring.unescape(str);`.