QString convert unicode
-
Hi,
You could use some of QString's static convert methods, like: fromLatin1();
The available methods are mentioned here: http://doc.qt.io/qt-5/qstring.html#static-public-membersElse you could use a QTextCodec which haves support for a number of character sets, take a look at: http://doc.qt.io/qt-5/qtextcodec.html
-
Sorry for this but i have one question that idk because i read lot that qstring is internally unicode. But if i have different string's or char's how i can do fast the conversion to unicode Utf8??
Use
QString::toUtf8()
and/orQString::fromUtf8()
. -
@Jeronimo said in QString convert unicode:
So i can convert in utf16 like
You're doing it wrong.
But i want to pass to unicode utf8
As I said, use QString::toUtf8:
wchar_t buffer[5] QString string = QString::fromWCharArray(buffer); char * utf8encoded = string.toUtf8();
-
@Jeronimo said in QString convert unicode:
So i can convert in utf16 like
You're doing it wrong.
But i want to pass to unicode utf8
As I said, use QString::toUtf8:
wchar_t buffer[5] QString string = QString::fromWCharArray(buffer); char * utf8encoded = string.toUtf8();
@kshegunov said in QString convert unicode:
wchar_t buffer[5]
say me the follow:
'inicializando' : no se puede realizar la conversi¢n de 'QByteArray' a 'char *'
No hay disponible ning£n operador de conversi¢n definido por el usuario que pueda realizar esta conversi¢n, o bien no se puede llamar al operadorIn other words when i do this
wchar_t buffer[5]; QString string = QString::fromWCharArray(buffer); char *utf8encoded = string.toUtf8();
I can't do the conversion.
-
@kshegunov said in QString convert unicode:
wchar_t buffer[5]
say me the follow:
'inicializando' : no se puede realizar la conversi¢n de 'QByteArray' a 'char *'
No hay disponible ning£n operador de conversi¢n definido por el usuario que pueda realizar esta conversi¢n, o bien no se puede llamar al operadorIn other words when i do this
wchar_t buffer[5]; QString string = QString::fromWCharArray(buffer); char *utf8encoded = string.toUtf8();
I can't do the conversion.
You really should check the docs on this.
I've made a minor mistake, but it's easily correctable.QByteArray utf8data = string.toUtf8(); const char * utf8encoded = utf8data.constData();
-
You really should check the docs on this.
I've made a minor mistake, but it's easily correctable.QByteArray utf8data = string.toUtf8(); const char * utf8encoded = utf8data.constData();
@kshegunov said in QString convert unicode:
QByteArray utf8data = string.toUtf8();
const char * utf8encoded = utf8data.constData();one question normally i think must show unicode text like this :
Normally i can do this
QString::fromUtf16((ushort*)buffer)But i have one problem with this only show me in unicode when i am using some modificator like ctrl. It's for one keyboard in different languages.
-
@kshegunov said in QString convert unicode:
QByteArray utf8data = string.toUtf8();
const char * utf8encoded = utf8data.constData();one question normally i think must show unicode text like this :
Normally i can do this
QString::fromUtf16((ushort*)buffer)But i have one problem with this only show me in unicode when i am using some modificator like ctrl. It's for one keyboard in different languages.
I don't understand the question. Unicode has little to do with control or with the keyboard, it's an encoding for text, not a device driver ...
-
I don't understand the question. Unicode has little to do with control or with the keyboard, it's an encoding for text, not a device driver ...
@kshegunov i think is problem of my instance or i'm doing something wrong.
-
Hi,
Then tell us what you are trying to do.
-
That still doesn't explain what you are trying to do.
Why do you need all these conversion ?
-
That still doesn't explain what you are trying to do.
Why do you need all these conversion ?
-
Something like the QtVirtualKeyboard module ?
-
Something like the QtVirtualKeyboard module ?
-
Why not make use of Window's virtual keyboard ?