QString convert unicode
-
wrote on 4 Nov 2016, 14:21 last edited by
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??
-
wrote on 4 Nov 2016, 14:43 last edited by
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()
. -
wrote on 4 Nov 2016, 17:49 last edited by kshegunov 11 Apr 2016, 17:56
I edited your post by accident and its text was lost, I am sorry!
~kshegunov
-
@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();
wrote on 4 Nov 2016, 22:26 last edited by Jeronimo 11 Apr 2016, 22:26@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();
wrote on 4 Nov 2016, 22:53 last edited by@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 ...
wrote on 5 Nov 2016, 18:15 last edited by@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 ?
-
wrote on 6 Nov 2016, 00:16 last edited by Jeronimo 11 Jun 2016, 00:16This post is deleted!
4/19