Qt 5.10 How to convert data from Firebird database correctly. In the database, the data is buried in the encoding win1251. Hieroglyphs come into the application.

db.setConnectOptions("ISC_DPB_LC_CTYPE=WIN1251"); 

does not work.

Qt 5.10 does not work

 QTextCodec* codec = QTextCodec::codecForName("utf8"); QTextCodec::setCodecForCStrings(codec); 
  • 2
    QSqlQueryModel has a whole interface built on QString - strings that are independent of the encoding, so I don’t see what could be converted here ... maybe the server connection / storage settings are incorrectly set? - Fat-Zer 5:02 pm
  • @ Fat-Zer, there are no strings independent of the encoding. UTF-16 is used inside a QString , and when writing any external strings there, they are converted. - ߊߚߤߘ
  • one
    @ Fat-Zer, and yes, the questioner needs to convert the text in QString copying it into an external buffer with an associated conversion to Windows-1251. However, I do not know platform-independent ways to do this. - ߊߚߤߘ
  • A manual description of the mapping of Unicode characters to the appropriate Window-1251 codes may be appropriate. So, through std::map<QChar, char> . And then run through the characters in QString , match each of them through that std::map and write to the final buffer. True, it is not clear what to do with symbols that are missing in Windows 1251. - ߊߚߤߘ
  • one
    @Arhad, lol ... it's Qt, everything is stolen before us - Fat-Zer

0