Reputation: 3446
Until now I foolishly thought JavaScript's encodeURI()
would produce the same results as ASP classic's Server.URLEncode()
. Here's an example where that fails:
encodeURI("戦艦帝国") = "%E6%88%A6%E8%89%A6%E5%B8%9D%E5%9B%BD"
Server.URLEncode("戦艦帝国") = "%C6%88%A6%C8%89%A6%C5%B8%9D%C5%9B%BD"
Since I'm in a system that uses both languages, is there any encoding method in one that is guaranteed to produce the same encoding as a method in the other?
(Note: Server.UrlEncode(str)
is supposedly equivalent to HttpUtility.UrlEncode(str, Response.ContentEncoding)
)
Upvotes: 1
Views: 284
Reputation: 3509
This works for me, but be sure to save using UTF-8
<%Response.charset="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<%=Server.UrlEncode("戦艦帝国")%>
<br />
<script>document.write(encodeURI("戦艦帝国"))</script>
</body>
</html>
Upvotes: 1