Skip to content
  • Categories
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse

Odoo 中文社区

  1. Home
  2. Categories
  3. Odoo 新手求助
  4. 中文出现编码错误,应该如何设置?

中文出现编码错误,应该如何设置?

Scheduled Pinned Locked Moved Odoo 新手求助
5 Posts 3 Posters 5.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BraidTim
    wrote on last edited by
    #1

    某下拉框点击就出现
    UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
    看起来应该是字符编码问题,控制台中文显示[(2, u'W2'), (2, u'\u8d27\u54c11')]。
    这是unicode没有主动转成中文吗?有时候浏览器弹出的错误中的中文也显示的类似\u8d27的值。应该改哪儿才能解决这种错误?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kowky
      wrote on last edited by
      #2

      str.decode("utf8") 尝试一下

      B 1 Reply Last reply
      0
      • K Kowky

        str.decode("utf8") 尝试一下

        B Offline
        B Offline
        BraidTim
        wrote on last edited by
        #3

        @袭流苏2amor
        感觉应该是什么总设置的问题,不是一两行代码中文乱码的问题
        我记得之前装的odoo服务器出错的时候都能正确显示中文来着
        自己应用里面有什么地方有和语言编码相关的设置吗?

        1 Reply Last reply
        0
        • B Offline
          B Offline
          BraidTim
          wrote on last edited by
          #4

          odoo中文编码是怎么处理的?
          我看我py文件都有加上# -- coding: utf-8 --
          但是看控制台输出u'\u8d27\u54c11'这种应该是unicode编码吧?
          然后错误提示又显示ascii不能编码XXX
          怎么同时出现三种编码方式?
          我看数据库也是utf8的,问题出在哪儿呢?

          1 Reply Last reply
          0
          • JoshuaJ Offline
            JoshuaJ Offline
            Joshua
            管理员
            wrote on last edited by
            #5

            最好提供完整的server log,好定位问题

            【上海先安科技】(joshua AT openerp.cn),欢迎关注公众号:openerp_cn

            1 Reply Last reply
            0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Tags
            • Popular
            • Users
            • Groups