Logo Search packages:      
Sourcecode: kchmviewer version File versions  Download package

bool CHMFile::changeFileEncoding ( const char *  qtencoding  )  [private]

Change the current CHM encoding for internal files and texts. Encoding could be either simple Qt codepage, or set like CP1251/KOI8, which allows to set up encodings separately for text (first) and internal files (second)

Definition at line 1027 of file xchmfile.cpp.

References m_entityDecodeMap, and m_textCodec.

Referenced by guessTextEncoding(), and setCurrentEncoding().

{
      // Encoding could be either simple Qt codepage, or set like CP1251/KOI8, which allows to
      // set up encodings separately for text (first) and internal files (second)
      const char * p = strchr( qtencoding, '/' );
      if ( p )
      {
            char buf[128]; // much bigger that any encoding possible. No DoS; all encodings are hardcoded.
            strcpy( buf, qtencoding );
            buf[p - qtencoding] = '\0';
            
            m_textCodec = QTextCodec::codecForName( buf );
      
            if ( !m_textCodec )
            {
                  qWarning( "Could not set up Text Codec for encoding '%s'", buf );
                  return false;
            }
            
            m_textCodecForSpecialFiles = QTextCodec::codecForName( p + 1 );
      
            if ( !m_textCodecForSpecialFiles )
            {
                  qWarning( "Could not set up Text Codec for encoding '%s'", p + 1 );
                  return false;
            }
      }
      else
      {
            m_textCodecForSpecialFiles = m_textCodec = QTextCodec::codecForName (qtencoding);
      
            if ( !m_textCodec )
            {
                  qWarning( "Could not set up Text Codec for encoding '%s'", qtencoding );
                  return false;
            }
      }
      
      m_entityDecodeMap.clear();
      return true;
}


Generated by  Doxygen 1.6.0   Back to index