Qt, C++ - Reading control characters from a file -


this first time asking question please have patience me.

i'm trying read content of text file meant sent printer. in middle of characters define how label printed there control characters, stx, soh, cr, lf. in example, read contents of file , pass them data structure(array) in memory, append data , later send printer directly, erasing data in structure.

the function following:

void clientthread::readfile2structure(bool goodorbad) {     int = 0;     int j = 0;      // clean structure        // here clean structure      // according name comes arguments.     if(goodorbad == 1)     {         labelfile.setfilename(labelpathgood);         //qdebug() << "fez o set filepath" << labelpathgood;     }     else if(goodorbad == 0)     {         labelfile.setfilename(labelpathbad);         //qdebug() << "fez o set filepath" << labelpathbad;     }      if (!labelfile.open(qiodevice::readonly))     {         qdebug() << "unable open label definition file printergood.ini/printerbad.ini!";         return;     }     else     {         while (!labelfile.atend())         {            temporarystructure[i] = labelfile.readline();            i++;         }          // debug purposes only!         qdebug() << "structure";          for(j=0; j<=i; j++)         {             qdebug() << temporarystructure[j];         }     } } 

the data structure has following definition: qbytearray temporarystructure[50];

the file sent is: stx f259 crlf soh d stx l crlf stx l crlf d11 crlf pc crlf sc crlf h25 crlf 1w1c66000004100202000016036 crlf

the data in bold control characters.

in console, when execute function above, control characters appear small squares , crlf not appear.

why these different control characters appearing small squares , these going modified copying qbytearray array?

i'm afraid nothing comes out of printer , still haven't got 1 test with, freeserialport monitor way see if coming out right.

thank attention.

unicode has lot of characters and, far know, there no font, represents of them. characters, not represented (including non-printable characters), printed, using special glyph, commonly - square.

answering second part of question - qbytearray contains raw data , not modified on copying.

in order remove cr , lf use:

bytearray.replace('\n', ""); bytearray.replace('\r', ""); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -