Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions | Static Protected Attributes
ImportTranslate Class Reference

#include <ImportTranslate.h>

List of all members.

Static Public Member Functions

static PRBool ConvertString (const nsCString &inStr, nsCString &outStr, PRBool mimeHeader)
static nsImportTranslatorGetTranslator (void)
static nsImportTranslatorGetMatchingTranslator (const char *pCharSet)

Static Protected Attributes

static int m_useTranslator = -1

Detailed Description

Definition at line 44 of file ImportTranslate.h.

Member Function Documentation

PRBool ImportTranslate::ConvertString ( const nsCString inStr,
nsCString outStr,
PRBool  mimeHeader 
) [static]

Definition at line 43 of file ImportTranslate.cpp.

       if (inStr.IsEmpty()) {
              outStr = inStr;
              return( PR_TRUE);

       nsImportTranslator *pTrans = GetTranslator();
       // int               maxLen = (int) pTrans->GetMaxBufferSize( inStr.Length());
       // int               hLen = 0;
       nsCString     set;
       nsCString     lang;

       if (mimeHeader) {
              // add the charset and language
              pTrans->GetCharset( set);
              pTrans->GetLanguage( lang);
       // Unfortunatly, we didn't implement ConvertBuffer for all translators,
       // just ConvertToFile.  This means that this data will not always
       // be converted to the charset of pTrans.  In that case...
       // We don't always have the data in the same charset as the current
       // translator...
       // It is safer to leave the charset and language field blank

       PRUint8 *     pBuf;
       pBuf = (P_U8) outStr.GetBuffer( maxLen);
       if (!pBuf) {
              delete pTrans;
              return( FALSE);
       pTrans->ConvertBuffer( (PC_U8)(PC_S8)inStr, inStr.GetLength(), pBuf);
       outStr = inStr;
       delete pTrans;

       // Now I need to run the string through the mime-header special char
       // encoder.

       pTrans = new CMHTranslator;
       pBuf = new PRUint8[pTrans->GetMaxBufferSize( outStr.Length())];
       pTrans->ConvertBuffer( (const PRUint8 *)(outStr.get()), outStr.Length(), pBuf);
       delete pTrans;
       if (mimeHeader) {
              outStr = set;
              outStr += "'";
              outStr += lang;
              outStr += "'";
       outStr += (const char *)pBuf;
       delete [] pBuf;

       return( PR_TRUE);

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 127 of file ImportTranslate.cpp.

       CString              jp = "iso-2022-jp";
       if (!jp.CompareNoCase( pCharSet))
              return( new CSJis2JisTranslator);

       return( nsnull);

Definition at line 106 of file ImportTranslate.cpp.

       if (m_useTranslator == -1) {
              // get the translator to use...
              // CString           trans;
              // trans.LoadString( IDS_LANGUAGE_TRANSLATION);
              m_useTranslator = 0;
              // if (!trans.CompareNoCase( "iso-2022-jp"))
              //     gWizData.m_useTranslator = 1;

       switch( m_useTranslator) {
       case 0:
              return( new nsImportTranslator);
       //case 1:
       //     return( new CSJis2JisTranslator);
              return( new nsImportTranslator);

Here is the caller graph for this function:

Member Data Documentation

int ImportTranslate::m_useTranslator = -1 [static, protected]

Definition at line 51 of file ImportTranslate.h.

The documentation for this class was generated from the following files: