curl - 使用 Curl 向 Web Api 发出 POST 请求 - 字符编码问题

标签 curl unicode character-encoding asp.net-web-api fiddler

我们有一个接受 POST 请求的 WebApi 服务。 POST 请求中的信息具有此 Unicode 字符 - ¡ ( http://www.fileformat.info/info/unicode/char/a1/index.htm )

当我们使用 Fiddler 测试服务时,信息在服务器上正确接收。但是在使用 curl 执行相同信息的 POST 时,字符会从 Specials 块更改为这个字符 - http://www.fileformat.info/info/unicode/char/fffd/index.htm

关于为什么会发生这种情况以及我们如何获得 Curl 请求以 POST 正确编码的内容的任何想法将不胜感激

编辑:
curl 请求

curl --trace-ascii debug.txt -d "=VALT ¡ OFFER = '111501383'" http://localhost:25980/api/uni

Api Controller 代码
// POST api/<controller>
public string Post([FromBody]string value)
{
// code to process the value
}

Fiddler 请求(使用 Composer 选项卡)
POST http://localhost:25980/api/uni HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-IN,en;q=0.5
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)
Content-Type: application/x-www-form-urlencoded; charset=US-ASCII
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Content-Length: 47
Host: localhost:25980

"=VALT ¡ OFFER = '111501383'"

最佳答案

这是一个建议。我将在今天晚些时候尝试复制您的问题并更新答案。

Content-Type: application/x-www-form-urlencoded; charset=US-ASCII



此行指定您的数据使用 US-ACSII 进行编码编码方案,不包括 ¡特点。尝试将其设置为 UTF-8使用此选项:
-H "Content-Type: application/x-www-form-urlencoded; charset=utf-8"

关于curl - 使用 Curl 向 Web Api 发出 POST 请求 - 字符编码问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20174259/

相关文章:

php - 如何检查文件夹是否已存在于谷歌驱动器中?

java - 如何将 ElasticSearch 多重匹配搜索查询从 cURL 转换为 JAVA?

mysql - sql:从cp1251转换为utf8

java - 不支持的字符集异常 : Cp1027 with DB2 JDBC Driver

字符到位表示

php - Codeigniter restclient 不工作

mongodb - 无法在 Ubuntu 18.4LTS 上安装 CURL(需要 libcurl4),但安装它会删除 libcurl3,因此 mongo 无法正常工作

sql - 绕过在字符串文字中添加前缀 N 的需要

javascript - 为什么 Δ 不是 JavaScript 中的有效标识符?

c++ - 使用 QIODevice::write 方法添加 "&#xd; "而不是回车