Changes between Initial Version and Version 1 of Ticket #9797, comment 15


Ignore:
Timestamp:
May 5, 2012, 10:18:09 AM (8 years ago)
Author:
stuartm
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #9797, comment 15

    initial v1  
    33It 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.
    44As 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{{{
    66QApplication app (argc, argv);
    77setlocale (LC_ALL, "");
     
    1414     const QString & filename = "привет!";
    1515     QString fn = filename.toLocal8Bit (). Data ();
    16 
     16}}}
    1717In this code, the value of variable fn will be appropriate encoding of the locale.
    1818
    1919In the code:
    20 
     20{{{
    2121QTextCodec * vpCodec = QTextCodec :: codecForLocale ();
    2222     if (vpCodec) {
     
    2626     const QString & filename = "/ hello";
    2727     QString fn = filename.toLocal8Bit (). Data ();
    28 
     28}}}
    2929no 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")
    3030