PDA

View Full Version : is there QUtf8String similar as QLatin1String?



cic
13th June 2013, 08:25
as the documentation stated in QLatin1String, it is a wrapper class to fasten the construction rather than calling QString(),
in my project the QLatin1String is not sufficient since many characters are e.g. "ü", "ä", ...

that's why im searching for a class like QUtf8String which specifically for utf8 string. However, seems like qt didnt offer such a class.
any one knows some classes like that in QT? maybe in different fancy name that I couldnt notice... thank you.

wysota
13th June 2013, 08:35
QString::fromUtf8(). Or QStringLiteral in Qt5.

cic
13th June 2013, 09:30
thx, @wysota.

Since im still using qt 4.8 currently, i think i need to make similar macro by using fromUtf8() in the code, cause there are more than thousand positions which i used QLatin1String("....") already.

wysota
13th June 2013, 11:38
Search and replace is your friend. However be aware that using fromUtf8() will not speed up your strings -- each call to that function will construct a real QString from utf-8 data. It only makes sure your strings are encoded properly.