Answer the question
In order to leave comments, you need to log in
C++QT5: UTF-8, QString, QByteArray, *char and Russian characters. How to change element in *char array?
There is a QString in UTF-8, I need to get an *char array from it, I do this:
QString word = "Слово";
QByteArray ar = word.toUtf8();
char* FirstArray = ar.data();
FirstArray[0] = 'X';
QString word1 = QString::fromUtf8(ar.data());
Answer the question
In order to leave comments, you need to log in
In UTF-8 encoding, one character is one to four bytes. Humble yourself, and if you want to change the Russian letter (2 bytes) to English (1 byte), it is better to work in UTF-16 encoding.
word1 = word;
word1[0] = 'X';
word1 = QString::fromUtf8(ar.data());
word1[0] = 'X';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question