string - Clean up QByteArray from \0 -


I use QByteArray in my app with fixed size of a byte record from binary data file I do read. Actually all of these records are wire if the string size is low record size, then the remaining bytes are filled with \ 0. Sometimes the record can start with \ 0.

Example, what I have to do:

Earlier

  \ 0 \ 0 \ 0t is \ 32 string \ 0 \ 0 \ 0 After   

  T that 32 string   

then my question - I QByteArray How can I clean from everyone?

I tested this code and it seems that QByteArray & amp; QByteArray :: Change (...) function.

  QByteArray array; Array [0] = '\ 0'; Array [1] = 'A'; Array [2] = '\ 0'; Array [3] = 'b'; Array [4] = '\ 0'; QDebug () & lt; & Lt; "String:" & lt; & Lt; QString (array.toHex ()); Array.replace ('\ 0', ""); QDebug () & lt; & Lt; "String:" & lt; & Lt; QString (array.toHex ());   

Output:

  string: "0061006200" string: "6162"    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -