V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
honmaple
V2EX  ›  Python

socketio 无法发送中文

  •  
  •   honmaple · 2016-07-01 23:16:06 +08:00 · 2033 次点击
    这是一个创建于 2856 天前的主题,其中的信息可能已经有所发展或是发生改变。

    使用 flask-socketio 写了一个网页在线聊天,chat
    本地上是可以发送中文的,但是部署到服务器上就无法发送中文,这是什么原因?

    代码在这

    部署采用的是 gunicorn + supervisor + nginx

    请教这个该如何处理?

    3 条回复    2016-07-03 02:43:01 +08:00
    guokeke
        1
    guokeke  
       2016-07-02 18:34:19 +08:00
    简单一点可以这么干:在发送之前把信息都 base64 编码再发送,接到的信息解码再显示。

    我找到些我觉得有用的东西
    https://www.base64decode.org/
    https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
    ryd994
        2
    ryd994  
       2016-07-03 01:59:40 +08:00 via Android
    多半是编码问题
    很多服务器上默认 LANG 是 C 或者 en_US
    你可以试试用 Python3 或者设置好 LANG
    fy
        3
    fy  
       2016-07-03 02:43:01 +08:00
    去年用的时候 socketio 的支持很差,与 nodejs 版的版本号有点远,于是一只用 sockjs 至今。

    楼主你这个是要看 log 的呀
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   966 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 22:12 · PVG 06:12 · LAX 15:12 · JFK 18:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.