c# - EPSON ESCPOS QRCode >380 characters not print -


i can not print more 380 characters in qr code .

follows code in c # :

    protected asciiencoding m_encoding = new asciiencoding(); string qrdata = @"35150909165024000175590000193130072726117830|20150924062259|50.00||hdmepier6rjzkyka+4+voi1nncxsagfbyseeqnh04sbvuei/hauf4gubpxt6q2uhf9f8qygxiwxwo3gxrrvj4wnnetygaquaymoanpitnkow0cppmz4r8i1zolnftvhkscm0zrl4rikgoazbn44huu2nqf0w/jlvfxzxu12jlcsthntmyj6m9wbsmc/sf9be14hdoxmykriqyt5tkejilhh9ffa0saryuip+fji89/moq8yccfc+qc44xgxsvnceehunoc1lgpp0dbu1miwpvnrblel87ru8iy0r8fn/fnhbcstkwftevhyvzz42nekhrmgtpgzykhutfcnzpq7aca==";         int store_len = qrdata.length + 3;                         byte store_pl = (byte)(store_len % 256);                         byte store_ph = (byte)(store_len / 256);                            string txt = m_encoding.getstring(new byte[] { 29, 40, 107, store_pl, store_ph, 49, 80, 48 }); //function 180             txt += qrdata;             txt += m_encoding.getstring(new byte[] { 29, 40, 107, 3, 0, 49, 69, 48 });//function 169             txt += m_encoding.getstring(new byte[] { 29, 40, 107, 3, 0, 49, 67, 5 });//function 167             txt += m_encoding.getstring(new byte[] { 29, 40, 107, 4, 0, 49, 65, 50, 0 });//function 165             txt += m_encoding.getstring(new byte[] { 29, 40, 107, 3, 0, 49, 81, 48 });//function 181 

when trying print appears follows:

print

ascii problem, since 7-bit encoding, store_pl value greater 127 (takes 8 bits). following demonstration of whats going on:

asciiencoding m_encoding = new asciiencoding(); string qrdata = @"35150909165024000175590000193130072726117830|20150924062259|50.00||hdmepier6rjzkyka+4+voi1nncxsagfbyseeqnh04sbvuei/hauf4gubpxt6q2uhf9f8qygxiwxwo3gxrrvj4wnnetygaquaymoanpitnkow0cppmz4r8i1zolnftvhkscm0zrl4rikgoazbn44huu2nqf0w/jlvfxzxu12jlcsthntmyj6m9wbsmc/sf9be14hdoxmykriqyt5tkejilhh9ffa0saryuip+fji89/moq8yccfc+qc44xgxsvnceehunoc1lgpp0dbu1miwpvnrblel87ru8iy0r8fn/fnhbcstkwftevhyvzz42nekhrmgtpgzykhutfcnzpq7aca=="; int store_len = qrdata.length + 3; // 414 byte store_pl = (byte)(store_len % 256); // 158 byte store_ph = (byte)(store_len / 256); // 1 byte[] data = new byte[] { 29, 40, 107, store_pl, store_ph, 49, 80, 48 }; //function 180 string txt = m_encoding.getstring(data); byte[] invaliddata = m_encoding.getbytes(txt); 

the original value of data (expected one):

1d 28 6b 9e 01 31 50 30 

the actual data serial port receives (due failure encode 158 value in 7-bit ascii):

1d 28 6b 3f 01 31 50 30 

as can see, value 158 (0x9e) changed 63 (0x3f), since unknown symbol encoded ?.

so, there 2 solutions problem. 1 use encoding m_encoding = encoding.getencoding("iso-8859-1"); encoding, or other extended ascii encoding, should synchronized between byte encoding use in code , settings of serial port. , solution not use strings @ all, use byte arrays.


Comments