我将来自nodejs的请求发送到服务器,并在我的网址中查询西里尔文本,如下所示:https://somesite.com/wf/server/postSomeStuff?id=13&name=Имя.pdf&other=true;
但服务器请Имя
与A;>1>60=I8=0
类似。 (例如)。我想让这个查询编码为unicode。我试图设置Accept-Charset
或Accept-Encoding
之类的标题,但它没有帮助..如何仅在网址中更改编码,而不是内容?
答案 0 :(得分:1)
您可以在发送请求之前使用javascript encodeURI函数
var url ='https://somesite.com/wf/server/postSomeStuff?id=13&name='+ encodeURI('Имя.pdf')+'& other = true';
并在服务器端解码它 var name = decodeURI(req.params.name);