mic*_*iuc 5 html forms post character-encoding cjk
我在搜索表单中发布中文字符时遇到了一些麻烦.它在localhost上工作得很好,但在我的网站上却不行.
搜索输入是这样的:假发
localhost上生成的url:http://search.taobao.com/search? tell = all& isnew = 2&q =% BC% D9%B7%A2&source = search1
在网站上得到的网址:StackOverflow实际编码它,编码结果不同,但网站上的东西不是q =%BC%D9%B7%A2我在网址本身得到q =假发. http://search.taobao.com/search?commend=all&isnew=2&q=%E5%81%87%E5%8F%91&source=search1
您可以看到它实际上将中文字符插入到查询中.我不知道为什么这在lcoahost和现场网站上的工作方式不同.字符编码是:
<meta http-equiv="Content-Type" content="text/html; charset=GB18030" />
Run Code Online (Sandbox Code Playgroud)
但我也试过UTF-8,没有变化.
这是我的表格的HTML.搜索查询转到第二个输入框.第一个用于转换,这很好.不确定是什么交易以及我是否必须对字符进行编码以及为什么它可以在localhost上工作?提前致谢!
<div class="search-box">
<form id="search" name="search" action="http://search1.taobao.com/browse/search_auction.htm?at_topsearch=1" method="post" target="_blank">
<div class="search-form">
<span class="search-q">
<input type="text" autocomplete="off" accesskey="s" name="q" id="q" value="Translate and Find" style="width: 160px; font-family: Arial;" size="20" />
</span>
<button id="DoSearch" type="submit" style="font-weight: bold; font-family:Arial; color: #333; width: 165px;">
Taobao Search</button>
</div>
<input type="hidden" name="sort" value="" />
<input type="hidden" name="at_topsearch" value="1" />
<input type="hidden" name="f" value="D9_5_1" />
<input type="hidden" name="promote" value="" />
<input type="hidden" name="isnew" value="2" />
<input type="hidden" name="atype" value="b" />
<input type="hidden" name="commend" value="all" />
<input type="hidden" name="search_type" value="auction" />
<input type="hidden" name="user_action" value="initiative" />
<input type="hidden" name="ssid" value="s1-e" />
</form>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
添加accept-charset="GB18030"到您的表单标签。我的猜测是,您的本地服务器将编码留给表单(例如 XAMPP 就是这样做的),并且实时服务器强制对信息进行编码。
如果这不起作用,您可以使用 PHP 对提交的信息强制进行编码。或者,如果您有能力修改服务器设置,则可以更改编码......但 PHP 选项要简单一百万倍。
| 归档时间: |
|
| 查看次数: |
3707 次 |
| 最近记录: |