小编Kar*_*ina的帖子

Curl post给出了像åäö这样的奇怪角色

我有一个带有后期操作的grails控制器.现在,当通过php和curl尝试发布到grails控制器时,我得到?了像åäö等等字符的占位符.如果我创建一个小的html表单,同样的帖子,grails控制器接收参数,åäö而不是?,等等.

下面的差异是什么?如何让curl充当html表单示例?

卷曲的例子:

$x = curl_init("http://localhost/post");      
curl_setopt($x, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));  
curl_setopt($x, CURLOPT_POST, 1);  
curl_setopt($x, CURLOPT_POSTFIELDS, "Foo=ö");  
curl_setopt( $x, CURLOPT_ENCODING, "UTF-8" );   
curl_setopt($x, CURLOPT_RETURNTRANSFER, 1);  
$data = curl_exec($x);   
curl_close($x);
Run Code Online (Sandbox Code Playgroud)

html表单示例:

<html> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head><title></title></head>
<body>
<form name="input" action="http://localhost/post" method="post" enctype="application/x-www-form-urlencoded">
<TEXTAREA NAME="Foo" COLS=10 ROWS=4 type=text>ö</TEXTAREA>
<input class="button" type="submit" value="send"/>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

php grails encoding curl

3
推荐指数
1
解决办法
6252
查看次数

标签 统计

curl ×1

encoding ×1

grails ×1

php ×1