Quote Originally Posted by caduel View Post
Wasn't trUtf8() introduced with Qt4.5?

I don't quite see why you don't just copy it by assigning (assuming qsOriginalStr is really a meaningful QString and not just some byte array that was wrongly de/encoded.)
Qt Code:
  1. QString temp = qsOriginalStr;
To copy to clipboard, switch view to plain text mode 
trUtf8() is in Qt 4.4 too. If i assign qsOriginalStr directly, it gives me junk characters, so i have to use trUtf8() to get the proper encoded string.

Quote Originally Posted by caduel View Post
Qt Code:
  1. QString temp = qsOriginalStr.toUtf8();
To copy to clipboard, switch view to plain text mode 
This code will produce a QByteArray with the UTF-8 encoding of your string. Those bytes will then (by the default encoding, whatever that might be in your case) converted back into a string. Quite plausible that this will not get you what you want.
This was the existing code which wasn't written by me.
Quote Originally Posted by caduel View Post
Qt Code:
  1. QString temp = trUtf8(qsOriginalStr);
To copy to clipboard, switch view to plain text mode 
To be honest, I don't see how that should compile either.
Looking at the sources trUtf8 wants a char* (no overloads for QString; at least not in 4.5.0; and also no implicit QString -> char* casts.)
I don't get any compilation errors so i think it implicitly converts the QString to char *
Should i do like this:

Qt Code:
  1. QString temp = trUtf8(qsOriginalStr.toLatin1().data());
To copy to clipboard, switch view to plain text mode