QMap<QString, QString> example { {"а", "$$$"}, {"б", "$$%"}, {"в", "$%%"}, {"a", "-1-"}, {"b", "-+="}, {"c", "dna"}, {"d", "dsv"} } ba = text.toLocal8Bit(); char texter[10000]; for (col=0;col<=text.length();col++){ it = example.begin(); texter[col] = ba[col]; while(it != example.end()){ it++; if(it.key() == texter[col]){ hash_string_text += it.value(); break; } } 

With characters in English. Everything is normal. But if you look for keys written in Russian, they are not visible.

  • 3
    Who is he? Give a normal minimal reproducible example . And the code text, but not a picture must be given. - αλεχολυτ
  • Please provide code with text, not a picture. Put a minus for a bad design issue. - AK
  • @ älёxölüt I do not know what else to bring you. There is a QMap with Russian keys, if I try to find Russian keys in it. He (QMap) does not find these keys. Question number 1 How to make them (KEYS) was visible? So that I can get the value, referring to the key with Russian letters. - clever clever
  • 2
    Apart from me, the question was not understood by at least 4 more people, so your question was closed so that you would bring it to a state that other people understand, and not just you. - αλεχολυτ
  • one
    Removed a minus and voted for re-opening the issue. - AK

1 answer 1

QString is a Unicode string. You compare it not so much with a single-byte string, but with a single single-byte character:

 if(it.key() == texter[col]) 

It is clear that such a comparison will never give the truth for keys that are not represented by a single byte.

  • Can you tell me how to solve this problem? For example, how to take each character in turn from QString and compare it with keys so that QMap does not swear afterwards? - clever clever 1:09 pm
  • @cleverclever you can get a single character from a QString via operator[] . Actually, as for most string classes. - αλεχολυτ pm