qt - bluetooth receipt printer - cannot change codepage of printer -


i have following setup:

  1. workstation ubuntu 14.04.3 lts using kernel linux work002 3.19.0-47-generic #53~14.04.1-ubuntu smp mon jan 18 16:09:14 utc 2016 x86_64 x86_64 x86_64 gnu/linux qt 5.5.1 opensource 64bit
  2. some usb<-->bluetooth dongle, has been working fine
  3. bluetooth based noname 48mm receipt printer china, shipped me without documentation (assuming esc/pos command set).

now, setup seems (initial connection, pairing , once paired blue led diode turns on on printer) work because can print text on printer via qbluetoothsocket::write method:

this->uebtprintersocket()->write(qbytearray("printer ready. @[\\]^`{|}~ ĐŠŽĆČđšžćč")); 

however, slovenia , need slovene letters, why put slovene letters upper write - ĐŠŽĆČđšžćč , chinese letters instead. therefore tried change printer code page according esc t n function, without success:

qbytearray cmdchangecodepagetoslovene;    // esc t n cmdchangecodepagetoslovene.resize(3); cmdchangecodepagetoslovene[0]=0x1b; cmdchangecodepagetoslovene[1]=0x74; cmdchangecodepagetoslovene[2]=0x18; qint64 result=this->uebtprintersocket()->write(cmdchangecodepagetoslovene);  qdebug() << q_func_info          << " bytes written:"          << result; 

qdebug() output notified me:

void uebluetoothmanager::ueslotbtprinterpairedandconnected() bytes written: 3

which ok. now, chinese manufacturer sent me code android, can hardly called sdk , there single .jar library working printer. i've uploaded .jar file decompilers online website , i've found following decompiled method changing printer's codepage:

public int setcharacterset(int value) {     if (g_nconnect != 1) {         return 101;     }     if (!(value > 0 && value < 10 || value > 16 && value < 19 || value != 255)) {         return 104;     }     byte[] send = new byte[]{27, 116, 1};     send[2] = (byte)value;     try {         out.write(send);         return 0;     }     catch (ioexception e) {         e.printstacktrace();         return 402;     } } 

which same qt code changing codepage of printer (and because of can assume high probability printer command set @ least basic esc/pos), can assume on right track. now, i've checked bluetooth traffic using wireshark, however, cannot find 0x1b 0x74 18 (command change codepage) datastream sent printer. maybe reason codepage not changed or can give me please guidelines? i've tried change codepage windows-1250 , iso8859-2: latin 2, no effect.

the problem seems did not convert utf-8 characters output charset.

qbytearray cmdsetcharset; cmdsetcharset.resize(3); cmdsetcharset[0] = 0x1b; cmdsetcharset[1] = 0x74; cmdsetcharset[2] = 0x2; //oem850  this->uebtprintersocket()->write(cmdsetcharset);  qtextcodec *codec = qtextcodec::codecforname("ibm850"); this->uebtprintersocket()->write(codec->fromunicode(qstring("ÄäÖöÜüß$€")) ); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -