L
L
Loligan2015-06-10 17:46:39
Qt
Loligan, 2015-06-10 17:46:39

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

2 answer(s)
S
Stanislav Makarov, 2015-06-10
@Loligan

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.

G
GavriKos, 2015-06-10
@GavriKos

Either use only ASCII (probably need to decode accordingly), or use wstring.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question