Changes between Initial Version and Version 1 of Ticket #9797, comment 15
- Timestamp:
- 05/05/12 10:18:09 (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #9797, comment 15
initial v1 3 3 It seems that replacing filename.toLatin1 () on filename.toLocal8Bit () in file BDRingBuffer.cpp (DVDRingBuffer.cpp in the file it is) we will solve the problem, but in reality it is not. 4 4 As I understand the problem is that outside of the context object QApplication and QCoreApplication Qt does not know about local encoding. And in the code of BDRingBuffer.cpp and DVDRingBuffer.cpp this context is not exists, so we have to explicitly specify the encoding for strings with codecForName. Here's an example: 5 5 {{{ 6 6 QApplication app (argc, argv); 7 7 setlocale (LC_ALL, ""); … … 14 14 const QString & filename = "привет!"; 15 15 QString fn = filename.toLocal8Bit (). Data (); 16 16 }}} 17 17 In this code, the value of variable fn will be appropriate encoding of the locale. 18 18 19 19 In the code: 20 20 {{{ 21 21 QTextCodec * vpCodec = QTextCodec :: codecForLocale (); 22 22 if (vpCodec) { … … 26 26 const QString & filename = "/ hello"; 27 27 QString fn = filename.toLocal8Bit (). Data (); 28 28 }}} 29 29 no object QApplication, Qt will use the default encoding, and our code will work only if we specify the codec with, for example QTextCodec :: codecForName ("UTF-8") 30 30
