如何使用 curl 使用 UTF-8 编码发布表单数据? [英] How do I POST form data with UTF-8 encoding by using curl?
本文介绍了如何使用 curl 使用 UTF-8 编码发布表单数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在终端提示上使用 cURL
POST
(发送)一些表单数据到网络服务器.
I would like to POST
(send) some form data to a webserver using cURL
on a terminal-prompt.
这是我目前得到的:
curl --data-ascii "content=derinhält&date=asdf" http://myserverurl.com/api/v1/somemethod
问题是元音变音(äöü")被?"代替了当我在服务器上收到 post 请求时.
The problem is that the umlaute ("äöü") are replaced by "?" when I receive the post request on the server.
我想我需要对 POST
请求使用 UTF-8 编码.
I think I need to use an UTF-8 encoding for the POST
request.
有人知道我如何实现这一目标吗?
Does anybody know how I can achieve this?
推荐答案
您可以在 POST 请求中使用 UTF-8,您只需要在请求中指定字符集即可.
You CAN use UTF-8 in the POST request, all you need is to specify the charset in your request.
您应该使用此请求:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" --data-ascii "content=derinhält&date=asdf" http://myserverurl.com/api/v1/somemethod
这篇关于如何使用 curl 使用 UTF-8 编码发布表单数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文