Code:
<script type="text/javascript">
var uri = "%^my test**.asp?name=ståle&car=saab";
document.write(decodeURI(uri));
</script>
Error:
Line: 6
Error: The URI to be decoded is not a valid encoding
Is there anyway of decoding the binations like %^ before calling the actual decodeURI?
Code:
<script type="text/javascript">
var uri = "%^my test**.asp?name=ståle&car=saab";
document.write(decodeURI(uri));
</script>
Error:
Line: 6
Error: The URI to be decoded is not a valid encoding
Is there anyway of decoding the binations like %^ before calling the actual decodeURI?
Share Improve this question edited Dec 31, 2019 at 20:19 Jeff Mergler 1,54422 silver badges30 bronze badges asked Nov 26, 2009 at 7:25 balalakshmibalalakshmi 4,2366 gold badges42 silver badges48 bronze badges 3- 2 are you sure you dont mean to "encode" rather than decode? – Ayyash Commented Nov 26, 2009 at 7:31
- 1 Why is that %^ in the URI anyway, and what do you want it to be decoded to? – Carl Smotricz Commented Nov 26, 2009 at 7:32
- 1 Agreed, at least why is % there, because it is the escape character for encoding other URI entities. Plus you have other non ASCII characters in the URI, which should be encoded, as it isn't safe to assume Unicode characters can be handled in URIs – Kitson Commented Nov 26, 2009 at 8:18
1 Answer
Reset to default 4That is not a valid URI. URIs aren't allowed to contain unencoded non-ASCII or reserved characters. You can't use literal %
, it has to be encoded as %25
.
var uri="%25^my%20test.asp?name=st%C3%A5le&car=saab";