Answer the question
In order to leave comments, you need to log in
Saving and loading binary files with Russian Qt text in string. How?
Good afternoon. My point is this. I save a class object with strings (and yes, I can’t convert it to QString, because it’s not up to me to decide) which I enter through LineEdit in the project window, which I later save through a binary file. I also load from the same place and save it, load everything into an object, after which I display the object's data in a label. How to save and load Russian text? I save and load through the overload of class operators.
Answer the question
In order to leave comments, you need to log in
It may not be necessary to convert strings from std::string to QString: it is enough for everyone to agree that std::string can contain UTF-8 text. Then you can no longer rely on the match symbol == element_string, i.e. your std::string will no longer store characters, but bytes (!) of the string, and size() will already show the number of bytes. If you only need to save / load, then this is just right for you. Then, to shove it into the control, do str.toUtf8() and QString::fromUtf8(...) in the right places and happiness.
If you need to process text character by character, for example cut a substring, then without unicode support you can't do anything. In this case, either use QString in text processing places, or include an ICU.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question