javascript - problems with decodeURI with %^ characters - Stack Overflow

Code:<script type="textjavascript">var uri = "%^my test**.asp?name=ståle&ca

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
Add a ment  | 

1 Answer 1

Reset to default 4

That 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";

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745497676a4630265.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信