Odoo 中文社区

    • 注册
    • 登录
    • 搜索
    • 版块
    • 标签
    • 热门
    • 用户
    • 群组

    Odoo中文社区可以通过以下两个域名访问:shine-it.net , odoo.net.cn

    由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

    本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

    开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

    如果您登录系统碰到问题,请在微信公众号留言:

    PosBox模块通过树莓派的硬件盒子打印出来的中文出现乱码

    Odoo 新手求助
    4
    12
    10082
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • V
      vFire 最后由 编辑

      最近一直在捣鼓树莓派的posbox,非常不错,唯一的问题就是。。。打印出来的中文乱码啊 ,同志们有研究过这个的没有,求指点~~~
      不是本地打印的那个哦,本地没问题,但是通过树莓派打印就不行,中文出现一堆的“北北北”这样的乱码字符,查看官方文档说ESCOP打印指令暂时还不支持中文,崩溃啊~~~

      1 条回复 最后回复 回复 引用 0
      • KevinKong
        KevinKong 最后由 编辑

        在escpos模块下的constants.py文件中第93行(附近)添加下面一行

        TXT_ENC_PC936 ='\x1C\x21\x00'
        


        然后在escpos.py文件的第813行附近添加下面一行:

         'cp936': TXT_ENC_PC936
        


        最后,在escpos.py文件中的第838行注释掉原来一行附近添加一行:

        #encoding = &#039;cp437&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp;  encoding = &#039;cp936&#039;
        



        即,在constants.py文件中添加对中文的编码支持,蓝后在escpos.py文件中引用新添加的encoding,最后的encode_char看起来大概是这个样子的:

        def encode_char(char):&nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Encodes a single utf-8 character into a sequence of <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; esc-pos code page change instructions and character declarations <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; char_utf8 = char.encode(&#039;utf-8&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encoded&nbsp; = &#039;&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encoding = self.encoding # we reuse the last encoding to prevent code page switches at every character<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encodings = {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # TODO use ordering to prevent useless switches<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # TODO Support other encodings not natively supported by python ( Thai, Khazakh, Kanjis )<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp936&#039;: TXT_ENC_PC936,&lt;-----新加的<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp437&#039;: TXT_ENC_PC437,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp850&#039;: TXT_ENC_PC850,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp852&#039;: TXT_ENC_PC852,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp857&#039;: TXT_ENC_PC857,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp858&#039;: TXT_ENC_PC858,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp860&#039;: TXT_ENC_PC860,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp863&#039;: TXT_ENC_PC863,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp865&#039;: TXT_ENC_PC865,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp866&#039;: TXT_ENC_PC866,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp862&#039;: TXT_ENC_PC862,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp720&#039;: TXT_ENC_PC720,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;iso8859_2&#039;: TXT_ENC_8859_2,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;iso8859_7&#039;: TXT_ENC_8859_7,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;iso8859_9&#039;: TXT_ENC_8859_9,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp1254&#039;&nbsp;  : TXT_ENC_WPC1254,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp1255&#039;&nbsp;  : TXT_ENC_WPC1255,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp1256&#039;&nbsp;  : TXT_ENC_WPC1256,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp1257&#039;&nbsp;  : TXT_ENC_WPC1257,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;cp1258&#039;&nbsp;  : TXT_ENC_WPC1258,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;katakana&#039; : TXT_ENC_KATAKANA,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; remaining = copy.copy(encodings)<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not encoding :<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #encoding = &#039;cp437&#039; &lt;----注释掉<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; encoding = &#039;cp936&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ……<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  
        



        然后再重启服务,你就会发现中文好使了。
        Good luck!

        1 条回复 最后回复 回复 引用 0
        • mrshelly
          mrshelly 最后由 编辑

          赞, 就是给 escpos 添加 cp936 编码 的支持吧?

          看整理一下 提到官网github 好了...
          谢谢 贡献...

          1 条回复 最后回复 回复 引用 0
          • mrshelly
            mrshelly 最后由 编辑

            https://github.com/fvdsn/py-xml-escpos/pull/5/files

            已提交给 py-xml-escpos 不知道官网什么时候能合并

            1 条回复 最后回复 回复 引用 0
            • KevinKong
              KevinKong 最后由 编辑

              直接提给Odoo官方不行么,我看他们都改了escpos的文件

              1 条回复 最后回复 回复 引用 0
              • V
                vFire 最后由 编辑

                太谢谢了~ 一下子就搞定了,之前联络了odoo的官方支持,他们也还没搞定或者说顾得上搞定,搜遍全网都没找到这个解决方法,兄弟,在上海不,我要请你吃饭。。。!!!版主,你可以来蹭一下~:)

                1 条回复 最后回复 回复 引用 0
                • KevinKong
                  KevinKong 最后由 编辑

                  [quote author=vFire link=topic=17116.msg30410#msg30410 date=1432651083]
                  太谢谢了~ 一下子就搞定了,之前联络了odoo的官方支持,他们也还没搞定或者说顾得上搞定,搜遍全网都没找到这个解决方法,兄弟,在上海不,我要请你吃饭。。。!!!版主,你可以来蹭一下~:)
                  [/quote]
                  哈哈,客气啦,我在北京不在上海,可以让校长和Joshua代我去吃啊,O(∩_∩)O哈哈~

                  1 条回复 最后回复 回复 引用 0
                  • V
                    vFire 最后由 编辑

                    [quote author=KevinKong link=topic=17116.msg30412#msg30412 date=1432691680]
                    [quote author=vFire link=topic=17116.msg30410#msg30410 date=1432651083]
                    太谢谢了~ 一下子就搞定了,之前联络了odoo的官方支持,他们也还没搞定或者说顾得上搞定,搜遍全网都没找到这个解决方法,兄弟,在上海不,我要请你吃饭。。。!!!版主,你可以来蹭一下~:)
                    [/quote]
                    哈哈,客气啦,我在北京不在上海,可以让校长和Joshua代我去吃啊,O(∩_∩)O哈哈~
                    [/quote]

                    那我去北京的时候怎么也得找你吃饭~ 把QQ密我~~~ 再次表示感谢~

                    1 条回复 最后回复 回复 引用 0
                    • mrshelly
                      mrshelly 最后由 编辑

                      OK , 官网  v8.0 分支已经合并进去了...
                      到时看看 master v9.0 分支是否合并...
                      <br / https://github.com/odoo/odoo/commit/8fe042ea917dad6a09fe69ef47ad6d6c4f3a72af br />

                      1 条回复 最后回复 回复 引用 0
                      • KevinKong
                        KevinKong 最后由 编辑

                        ;)Cool

                        不过看着你们沟通的过程,感觉朝官网提交个代码好费劲啊~~

                        1 条回复 最后回复 回复 引用 0
                        • P
                          podo 最后由 编辑

                          請問我們打印機(EPSON TM-T88IV)只有支援BIG5編碼

                          我們印出來的中文字都會顯示 控控控控

                          請問該如何修改呢?

                          1 条回复 最后回复 回复 引用 0
                          • First post
                            Last post