处理html表单提交中的UTF字符 [英] Handling UTF characters in html form submission

查看:102
本文介绍了处理html表单提交中的UTF字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的html表单有一些输入文本字段,可以从中文,日文,欧洲,特殊字符(如£)等中获取字符。所以简而言之,unicode字符。



要在服务器端(使用php)处理这些值,我可以假设所有浏览器都默认在提交表单时以UTF-8格式编码这些字符。或者是否有方法告诉浏览器始终将这些字符提交为UTF8编码,以便我们可以使用utf8_decode来处理这些值?



谢谢。

解决方案

在输出HTML之前,设置表单页面的字符编码。

  header('Content-Type:text / html; charset = utf-8'); 


My html form has a few input text fields which can potentially get characters from Chinese, japanese, european, special characters like £, etc. So, in short, unicode characters.

To process these values at the server side (with php), can I assume that all browsers by default encode these characters in UTF-8 format at the time of form submission.

Or is there is way to tell the browser to always submit these characters as UTF8 encoded , so that we can use the utf8_decode to process these values ?

Thanks.

解决方案

Set the character encoding for the form page before you output the HTML.

header('Content-Type: text/html; charset=utf-8');

这篇关于处理html表单提交中的UTF字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆