Re: Ascii control characters
What if you try
QString res = string.toUtf8().toHex();
Does it help ?
Re: Ascii control characters
Thanks for the quick reply, but no that doesn't work.
it alters the output to something totally different to what I am expecting
:(
Re: Ascii control characters
What format is your input ?
and also what data type is compressed_string2 ? c_str() doesnt seem to be Qt function
Re: Ascii control characters
My input is in a standard string format:
Code:
std::string compressed_string2;
c_str converts a regular string to a QString.
Re: Ascii control characters
Hi,
Hi,
QString::QString ( const QByteArray & ba )
Constructs a string initialized with the byte array ba. The given byte array is converted to Unicode using fromAscii(). Stops copying at the first 0 character, otherwise copies the entire byte array.
So
Code:
QString res
= string.
toAscii().
toHex();
stops at first '0' character
Re: Ascii control characters
thanks for the input.
That makes sense.
but if that is the case, then if I add
#define QT_NO_CAST_FROM_ASCII
should add the complete line to the string?
is that true?
it gives the same result if I try it.
Re: Ascii control characters
Hi,
I think that you have to add "48" to each char to obtain the desired character. Take a look at ASCII table where you can see that character "0" is 48 decimal. So this is basically a LUT.
Try it and tell if it helps you.
Re: Ascii control characters
thanks for all of your help
here is how I fixed it:
Code:
QString compressedString1
= QString::fromStdString(compressed_string1
);
QString compressedString1Q
= compressedString1.
toAscii().
toHex();
this seemed to fix the issue.