Skip to content

Codepage setting #312

@mrkolarik

Description

@mrkolarik

When trying to set different code page (trying to print in Czech) I am getting CharCodeError:

escpos.exceptions.CharCodeError: Valid char code must be set

when trying to set any other Code Page using Charcode function, my code:

#encoding=utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')
from escpos.printer import Usb
p = Usb(0x0483,0x5743,0)
p.charcode(" ??????? ")
veta='Žluťoučký kůň pěl ďábelské ódy.\n'
print(veta)
uveta=veta.encode('utf-8')
p.text(uveta)
p.cut()

Text is in Czech - trying anything other than USA or GREEK as an argument of charcode() fails with this error, without this setting I am unable to print anything in Czech (it works for non-czech characters).
When trying to print my code pages I got this:

�@�a�BUSA�b
�-

�t��a�B  0123456789abcdef
�!�a�B����     
�!�a�B����������� ����
�!�a�B !"#$%&'()*+,-./
�!�a�B0123456789:;<=>?
�!�a�B@ABCDEFGHIJKLMNO
�!�a�BPQRSTUVWXYZ[\]^_
�!�a�B`abcdefghijklmno
�!�a�Bpqrstuvwxyz{|}~
�!�a�B����������������
�!�a�B����������������
�!�a�B����������������
�!�a�B����������������
�!�a�B����������������
�!�a�B����������������
�!�a�B����������������
�!�a�B����������������
�-

This is output testing page from my printer with code pages:
codepages

My printer is Xprinter xp-q260nl. Any suggestions on how to make it work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions