html前端数据写入mysql_HTML发布的表单数据以jibberish的形式写入MySQL数据库

在使用WSGI_mod时,由于默认编码为ASCII,导致包含希腊字符的HTML表单数据以乱码形式写入MySQL数据库。为解决此问题,需设置服务器环境变量为UTF-8或iso-8859-1,特别是当Apache从系统初始化脚本启动时,可能使用默认的ASCII编码。推荐设置LANG或LOCALE环境变量为en_US.UTF-8以确保正确解码。
摘要由CSDN通过智能技术生成

根据wsgi_mod文档,WSGIDaemonProcess的默认编码是ASCII。ASCII中不包括希腊字符,并且您的输入未正确解码。如果要允许使用希腊字符,则必须使用UTF-8或iso-8859-1。通常服务器是由init系统启动的deamons,99%的情况下仍然使用ASCII作为默认编码。在开发或调试时,通常不会遇到这些问题,因为python脚本继承了当前用户的环境,而当前用户通常使用UTF-8。在$env

.....

LANG=en_GB.UTF-8

.....

引用apache的wsgi_mod:lang=locale

Set the current language locale. This is the same as having set the LANG environment variable.

You will need to set this on many Linux systems where Apache when started up from system init scripts uses the default C locale, meaning that the default system encoding is ASCII. Unless you need a special language locale, set this to en_US.UTF-8.

Whether the lang or locale option works best can depend on the system being used. Set both if you aren’t sure which is appropriate.

locale=locale

Set the current language locale. This is the same as having set the LC_ALL environment variable.

You will need to set this on many Linux systems where Apache when started up from system init scripts uses the default C locale, meaning that the default system encoding is ASCII. Unless you need a special language locale, set this to en_US.UTF-8.

Whether the lang or locale option works best can depend on the system being used. Set both if you aren’t sure which is appropriate.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值