我对 $_POST 的字符集有疑问。当我提交表单时,如果 InputText 上插入的字符串有特殊字符或重音符号,则 $_POST 数组上的此输入值因无效字符而损坏。
示例:我在输入上插入:“pão” $_POST 显示:Array ([input] => pão)
我正在使用带有 ISO-8859-1 字符集的 CodeIgniter 框架。为了改进我的测试,我使用了 mb_detect_encoding() 并且这个函数返回了 utf-8。:\
下面是重要部分的代码:
/*
|--------------------------------------------------------------------------
| Default Character Set
|--------------------------------------------------------------------------
|
| This determines which character set is used by default in various methods
| that require a character set to be provided.
|
*/
$config['charset'] = "iso-8859-1";
/*
|--------------------------------------------------------------------------
| Default Language
|--------------------------------------------------------------------------
|
| This determines which set of language files should be used. Make sure
| there is an available translation if you intend to use something other
| than english.
|
*/
$config['language'] = "portugues";
$db['default']['char_set'] = "latin1";
$db['default']['dbcollat'] = "latin1_swedish_ci";
Form that was submited:
<form action="HTTP://localhost/portalsibe/index.php/grupos/cadastro" id="form" accept-charset="utf8" method="POST" name="frmPadrao" target="" enctype="multipart/form-data">