home *** CD-ROM | disk | FTP | other *** search
- // Xceed Binary Encoding Library - Memory Encode sample
- // Copyright (c) 2001 Xceed Software Inc.
- //
- // [MemoryEncodeDlg.cpp]
- //
- // This form module contains the main form's code. It demonstrates how to
- // encode a chunk of memory data using different kinds of encoding methods,
- // and decode an encoded memory data. It specifically uses:
- // - The Encode and Decode method.
- // - The ContinueOnInvalidData, IncludeHeaderFooter, EndOfLineType, MaxLineLength,
- // HeaderDataForkLength, HeaderResourceForkLength and EncodingFormat propeties.
- //
- // This file is part of the Xceed Binary Encoding Library sample applications.
- // The source code in this file is only intended as a supplement to Xceed
- // Binary Encoding Library's documentation, and is provided "as is", without
- // warranty of any kind, either expressed or implied.
-
-
- #include "stdafx.h"
- #include "MemoryEncode.h"
- #include "MemoryEncodeDlg.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
-
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
-
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
-
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
-
- // Implementation
- protected:
- //{{AFX_MSG(CAboutDlg)
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
-
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
-
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CMemoryEncodeDlg dialog
-
- CMemoryEncodeDlg::CMemoryEncodeDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CMemoryEncodeDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CMemoryEncodeDlg)
- m_lEncodingMethod = -1;
- m_lEOLType = -1;
- m_lMaxLineLength = 0;
- m_sDecodedText = _T("");
- m_sEncodedText = _T("");
- m_sDecodedSize = _T("");
- m_sEncodedSize = _T("");
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
-
- void CMemoryEncodeDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CMemoryEncodeDlg)
- DDX_CBIndex(pDX, IDC_CBO_ENCODINGMETHOD, m_lEncodingMethod);
- DDX_CBIndex(pDX, IDC_CBO_EOLTYPE, m_lEOLType);
- DDX_Control(pDX, IDC_CBO_EOLTYPE, m_cboEOLType);
- DDX_Control(pDX, IDC_CBO_ENCODINGMETHOD, m_cboEncodingMethod);
- DDX_Text(pDX, IDC_TXT_MAXLINELENGTH, m_lMaxLineLength);
- DDX_Text(pDX, IDC_TXT_DECODEDTEXT, m_sDecodedText);
- DDX_Text(pDX, IDC_TXT_ENCODEDTEXT, m_sEncodedText);
- DDX_Text(pDX, IDC_LBL_DECODEDSIZE, m_sDecodedSize);
- DDX_Text(pDX, IDC_LBL_ENCODEDSIZE, m_sEncodedSize);
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CMemoryEncodeDlg, CDialog)
- //{{AFX_MSG_MAP(CMemoryEncodeDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_CMD_ENCODE, OnCmdEncode)
- ON_BN_CLICKED(IDQUIT, OnQuit)
- ON_EN_CHANGE(IDC_TXT_DECODEDTEXT, OnChangeTxtDecodedtext)
- ON_EN_CHANGE(IDC_TXT_ENCODEDTEXT, OnChangeTxtEncodedtext)
- ON_EN_SETFOCUS(IDC_TXT_DECODEDTEXT, OnSetfocusTxtDecodedtext)
- ON_EN_SETFOCUS(IDC_TXT_ENCODEDTEXT, OnSetfocusTxtEncodedtext)
- ON_BN_CLICKED(IDC_CMD_DECODE, OnCmdDecode)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CMemoryEncodeDlg message handlers
-
- BOOL CMemoryEncodeDlg::OnInitDialog()
- {
- //
- // Set default values for the text to encode and the MaxLineLength text box
- //
- m_sDecodedText = "This is a little test to show you how the memory encoding works. \r\n"
- "And it is very easy to use.";
- m_lMaxLineLength = 78;
-
- CDialog::OnInitDialog();
-
- // Add "About..." menu item to system menu.
-
- // IDM_ABOUTBOX must be in the system command range.
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
-
- CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
- CString strAboutMenu;
- strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
- pSysMenu->AppendMenu(MF_SEPARATOR);
- pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- }
- }
-
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
-
- //----------------------------------------------------------------------------------
- // Initialize the size labels and fill the 2 combo boxes
- //----------------------------------------------------------------------------------
-
- // Fill the combo boxes
- m_cboEncodingMethod.AddString( "UU encoding" );
- m_cboEncodingMethod.AddString( "XX encoding" );
- m_cboEncodingMethod.AddString( "Hexadecimal" );
- m_cboEncodingMethod.AddString( "Base 64" );
- m_cboEncodingMethod.AddString( "Quoted printable" );
- m_cboEncodingMethod.AddString( "BinHex" );
-
- m_cboEncodingMethod.SetItemData( 0, emUUEncode );
- m_cboEncodingMethod.SetItemData( 1, emXXEncode );
- m_cboEncodingMethod.SetItemData( 2, emHexadecimal );
- m_cboEncodingMethod.SetItemData( 3, emBase64 );
- m_cboEncodingMethod.SetItemData( 4, emQuoted );
- m_cboEncodingMethod.SetItemData( 5, emBinHex );
-
- m_cboEncodingMethod.SetCurSel( emUUEncode );
-
- m_cboEOLType.AddString( "None" );
- m_cboEOLType.AddString( "Carriage return/line feed" );
- m_cboEOLType.AddString( "Line feed" );
- m_cboEOLType.AddString( "Carriage return" );
-
- m_cboEOLType.SetItemData( 0, ltNone );
- m_cboEOLType.SetItemData( 1, ltCrLf );
- m_cboEOLType.SetItemData( 2, ltLf );
- m_cboEOLType.SetItemData( 3, ltCr );
-
- m_cboEOLType.SetCurSel( ltNone );
-
- OnChangeTxtDecodedtext();
- OnChangeTxtEncodedtext();
-
- return TRUE; // return TRUE unless you set the focus to a control
- }
-
- void CMemoryEncodeDlg::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
- }
-
- // If you add a minimize button to your dialog, you will need the code below
- // to draw the icon. For MFC applications using the document/view model,
- // this is automatically done for you by the framework.
-
- void CMemoryEncodeDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
-
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
-
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
-
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
-
- // The system calls this to obtain the cursor to display while the user drags
- // the minimized window.
- HCURSOR CMemoryEncodeDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
-
- //====================================================================================
- //
- // EVENTS - triggered by the form and its controls
- //
- //====================================================================================
-
- //------------------------------------------------------------------------------------
- // Update the decoded size label when the user modify the decoded text box content
- //------------------------------------------------------------------------------------
- void CMemoryEncodeDlg::OnChangeTxtDecodedtext()
- {
- if( UpdateData( TRUE ) )
- {
- m_sDecodedSize.Format( "%d", m_sDecodedText.GetLength() );
- UpdateData( FALSE );
- }
- }
-
- //------------------------------------------------------------------------------------
- // Update the encoded size label when the user modify the encoded text box content
- //------------------------------------------------------------------------------------
- void CMemoryEncodeDlg::OnChangeTxtEncodedtext()
- {
- if( UpdateData( TRUE ) )
- {
- m_sEncodedSize.Format( "%d", m_sEncodedText.GetLength() );
- UpdateData( FALSE );
- }
- }
-
- void CMemoryEncodeDlg::OnSetfocusTxtDecodedtext()
- {
- SetDefID( IDC_CMD_ENCODE );
- }
-
- void CMemoryEncodeDlg::OnSetfocusTxtEncodedtext()
- {
- SetDefID( IDC_CMD_DECODE );
- }
-
- //------------------------------------------------------------------------------------
- // Quit the sample application
- //------------------------------------------------------------------------------------
- void CMemoryEncodeDlg::OnQuit()
- {
- EndDialog( IDOK );
- }
-
- //------------------------------------------------------------------------------------
- // Do the encoding of the decoded text
- //------------------------------------------------------------------------------------
- void CMemoryEncodeDlg::OnCmdEncode()
- {
- if( UpdateData( TRUE ) )
- {
- CWaitCursor xWaitCursor;
-
- COleException* pExcept = new COleException;
- DXceedBinaryEncoding xEncoder;
- COleVariant vaEncoded;
- COleVariant vaToEncode;
-
- try
- {
- // Create an instance of the XceedBinaryEncoding class
- if( !xEncoder.CreateDispatch( "Xceed.BinaryEncoding", pExcept ) )
- {
- throw pExcept;
- }
-
- // Create and prepare the encoding format (XX, UU, BinHex, ...)
- // This function can throw an exception that will be caught here.
- PrepareEncodingFormat( xEncoder );
-
- // Store in the variant to encode the content of the text box
- // as an ANSI String. We could have used a BSTR representation
- // of the string but it would have unnecessarily double the string size.
- // The Variant will report containing a VT_BSTR, but the actual data and
- // size will reflect the Ansi string format.
- vaToEncode.SetString( m_sDecodedText, VT_BSTRT );
-
- // Encode the string in a single call (bEndOfData is TRUE).
- vaEncoded = xEncoder.Encode( vaToEncode, TRUE );
-
- // We assign an empty string as a default encoded value.
- m_sEncodedText = "";
-
- // We check that the encoded variant is really a byte array. For instance,
- // it won't be if there was no characters to encode (empty string).
- if( vaEncoded.vt == ( VT_ARRAY | VT_UI1 ) )
- {
- LONG lHigh;
- LONG lLow;
-
- // We extracts the upper bound and the lower bound of the
- // byte array.
- SafeArrayGetUBound( vaEncoded.parray, 1, &lHigh );
- SafeArrayGetLBound( vaEncoded.parray, 1, &lLow );
-
- // This pointer will contain the address of the byte array
- char* pszEncoded = NULL;
-
- // We get a pointer on the actual data in the safe array.
- SafeArrayAccessData( vaEncoded.parray, (void**)&pszEncoded );
-
- // We set the encoded string to the variable associated to the
- // encoded text box, specifying the length of the encoded string
- // using the upper and lower bound.
- m_sEncodedText = CString( pszEncoded, lHigh - lLow + 1 );
-
- // We release the lock on the safe array
- SafeArrayUnaccessData( vaEncoded.parray );
- }
-
- // Update mainly the encoded text box
- UpdateData( FALSE );
- }
- catch( COleDispatchException* pEx )
- {
- pEx->ReportError();
- pEx->Delete();
- }
- catch( COleException* pEx )
- {
- pEx->ReportError();
- pEx->Delete();
- }
- catch( CException* pEx )
- {
- pEx->ReportError();
- pEx->Delete();
- }
-
- pExcept->Delete();
-
- //Update the encoded text size label
- OnChangeTxtEncodedtext();
- }
- }
-
- //------------------------------------------------------------------------------------
- // Do the decoding of the encoded text
- //------------------------------------------------------------------------------------
- void CMemoryEncodeDlg::OnCmdDecode()
- {
- if( UpdateData( TRUE ) )
- {
- CWaitCursor xWaitCursor;
-
- COleException* pEx = new COleException;
- DXceedBinaryEncoding xEncoder;
- COleVariant vaEncoded;
- COleVariant vaDecoded;
-
- try
- {
- // Create an instance of the XceedBinaryEncoding class
- if( !xEncoder.CreateDispatch( "Xceed.BinaryEncoding", pEx ) )
- {
- throw pEx;
- }
-
- // Create and prepare the encoding format (XX, UU, BinHex, ...)
- // This function can throw an exception that will be caught here.
- PrepareDecodingFormat( xEncoder );
-
- // Store in the variant to decode the content of the text box
- // as an ANSI String. We could have used a BSTR representation
- // of the string but it would have unnecessarily double the string size.
- // The Variant will report containing a VT_BSTR, but the actual data and
- // size will reflect the Ansi string format.
- vaEncoded.SetString( m_sEncodedText, VT_BSTRT );
-
- // Decode the string in a single call (bEndOfData is TRUE).
- vaDecoded = xEncoder.Decode( vaEncoded, TRUE );
-
- // We assign an empty string as a default decoded value.
- m_sDecodedText = "";
-
- // We check that the decoded variant is really a byte array. For instance,
- // it won't be if there was no characters to decode (empty string).
- if( vaDecoded.vt == ( VT_ARRAY | VT_UI1 ) )
- {
- LONG lHigh;
- LONG lLow;
-
- // We extracts the upper bound and the lower bound of the
- // byte array.
- SafeArrayGetUBound( vaDecoded.parray, 1, &lHigh );
- SafeArrayGetLBound( vaDecoded.parray, 1, &lLow );
-
- // This pointer will contain the address of the byte array
- char* pszDecoded = NULL;
-
- // We get a pointer on the actual data in the safe array.
- SafeArrayAccessData( vaDecoded.parray, (void**)&pszDecoded );
-
- // We display the decoded string by assigning this Ansi string
- // to the CString member, using the constructor accepting a char* and a size.
- m_sDecodedText = CString( pszDecoded, lHigh - lLow + 1 );
-
- // We release the lock on the safe array
- SafeArrayUnaccessData( vaDecoded.parray );
- }
-
- // Update mainly the decoded text box
- UpdateData( FALSE );
- }
- catch( COleDispatchException* pExcept )
- {
- pExcept->ReportError();
- pExcept->Delete();
- }
- catch( COleException* pExcept )
- {
- pExcept->ReportError();
- pExcept->Delete();
- }
- catch( CException* pExcept )
- {
- pExcept->ReportError();
- pExcept->Delete();
- }
-
- pEx->Delete();
-
- // Update the decoded text size label
- OnChangeTxtDecodedtext();
- }
- }
-
- //====================================================================================
- //
- // FUNCTIONS
- //
- //====================================================================================
-
- //------------------------------------------------------------------------------------
- // Prepare the encoding format according to the user selection
- //------------------------------------------------------------------------------------
- void CMemoryEncodeDlg::PrepareEncodingFormat( DXceedBinaryEncoding& xEncoder )
- {
- if( UpdateData( TRUE ) )
- {
- COleException* pEx = new COleException;
-
- switch( m_lEncodingMethod )
- {
- case emUUEncode :
- {
- DXceedUUEncodingFormat xUUEncode;
-
- if( !xUUEncode.CreateDispatch( "Xceed.UUEncoding", pEx ) )
- {
- throw pEx;
- }
-
- // We don't want any header/footer for this is only a memory encoding
- // process. The header/footer are mainly useful with files.
- xUUEncode.SetIncludeHeaderFooter( FALSE );
- xUUEncode.SetEndOfLineType( m_lEOLType );
-
- // Set the maximum line length specified by the user. This is a mandatory
- // value as the EndOfLineType can not be None for UUEncoding.
- xUUEncode.SetMaxLineLength( m_lMaxLineLength );
-
- // Set the previously initialized Encoding format of the Encoder object
- // received as a parameter of this function.
- xEncoder.SetRefEncodingFormat( xUUEncode.m_lpDispatch );
-
- // Free the temporary encoding format. The previous assignation adding
- // a reference to the encoding format object, this object will effectively
- // be freed by the xEncoder object when the latter will be released.
- break;
- }
-
- case emXXEncode :
- {
- DXceedXXEncodingFormat xXXEncode;
-
- if( !xXXEncode.CreateDispatch( "Xceed.XXEncoding", pEx ) )
- {
- throw pEx;
- }
-
- // We don't want any header/footer for this is only a memory encoding
- // process. The header/footer are mainly useful with files.
- xXXEncode.SetIncludeHeaderFooter( FALSE );
- xXXEncode.SetEndOfLineType( m_lEOLType );
-
- // Set the maximum line length specified by the user. This is a mandatory
- // value as the EndOfLineType can not be None for XXEncoding.
- xXXEncode.SetMaxLineLength( m_lMaxLineLength );
-
- xEncoder.SetRefEncodingFormat( xXXEncode.m_lpDispatch );
- break;
- }
-
- case emBase64 :
- {
- DXceedBase64EncodingFormat xBase64;
-
- if( !xBase64.CreateDispatch( "Xceed.Base64Encoding", pEx ) )
- {
- throw pEx;
- }
-
- xBase64.SetEndOfLineType( m_lEOLType );
-
- // Set the maximum line length specified by the user. This value will
- // be ignored by the Xceed Binary Encoding Library if the End of line
- // type is set to None
- xBase64.SetMaxLineLength( m_lMaxLineLength );
-
- xEncoder.SetRefEncodingFormat( xBase64.m_lpDispatch );
- break;
- }
-
- case emBinHex :
- {
- DXceedBinHexEncodingFormat xBinHex;
-
- if( !xBinHex.CreateDispatch( "Xceed.BinHexEncoding", pEx ) )
- {
- throw pEx;
- }
-
- xBinHex.SetEndOfLineType( m_lEOLType );
-
- // For the BinHex format, we must specify the data fork length and the
- // resource fork length.
- // The DataForkLength is mandatory and must be set to the size
- // of the data that will be encoded.
- xBinHex.SetHeaderDataForkLength( m_sDecodedText.GetLength() );
-
- // The ResourceForkLength, used by MAC system, is not relevant
- // under a PC system. We set it to 0.
- xBinHex.SetHeaderResourceForkLength( 0 );
- xBinHex.SetIncludeHeaderFooter( FALSE );
-
- xEncoder.SetRefEncodingFormat( xBinHex.m_lpDispatch );
- break;
- }
-
- case emHexadecimal :
- {
- DXceedHexaEncodingFormat xHexa;
-
- if( !xHexa.CreateDispatch( "Xceed.HexaEncoding", pEx ) )
- {
- throw pEx;
- }
-
- xHexa.SetEndOfLineType( m_lEOLType );
-
- // Set the maximum line length specified by the user. This value will
- // be ignored by the Xceed Binary Encoding Library if the End of line
- // type is set to None
- xHexa.SetMaxLineLength( m_lMaxLineLength );
-
- xEncoder.SetRefEncodingFormat( xHexa.m_lpDispatch );
- break;
- }
-
- case emQuoted :
- {
- DXceedQuotedPrintableEncodingFormat xQuoted;
-
- if( !xQuoted.CreateDispatch( "Xceed.QuotedPrintableEncoding", pEx ) )
- {
- throw pEx;
- }
-
- xQuoted.SetEndOfLineType( m_lEOLType );
-
- // Set the maximum line length specified by the user. This value will
- // be ignored by the Xceed Binary Encoding Library if the End of line
- // type is set to None
- xQuoted.SetMaxLineLength( m_lMaxLineLength );
-
- xEncoder.SetRefEncodingFormat( xQuoted.m_lpDispatch );
- break;
- }
- }
-
- pEx->Delete();
- }
- }
-
- //------------------------------------------------------------------------------------
- // Prepare the decoding format according to the user selection
- //------------------------------------------------------------------------------------
- void CMemoryEncodeDlg::PrepareDecodingFormat( DXceedBinaryEncoding& xDecoder )
- {
- if( UpdateData( TRUE ) )
- {
- COleException* pEx = new COleException;
-
- switch( m_lEncodingMethod )
- {
- case emUUEncode :
- {
- DXceedUUEncodingFormat xUUEncode;
-
- if( !xUUEncode.CreateDispatch( "Xceed.UUEncoding", pEx ) )
- {
- throw pEx;
- }
-
- // The encoded string does not contain any header/footer
- // The header/footer are usually present only in files.
- xUUEncode.SetIncludeHeaderFooter( FALSE );
- // We want to ignore any invalid encoded characters
- xUUEncode.SetContinueOnInvalidData( TRUE );
- xDecoder.SetRefEncodingFormat( xUUEncode.m_lpDispatch );
- break;
- }
-
- case emXXEncode :
- {
- DXceedXXEncodingFormat xXXEncode;
-
- if( !xXXEncode.CreateDispatch( "Xceed.XXEncoding", pEx ) )
- {
- throw pEx;
- }
-
- xXXEncode.SetContinueOnInvalidData( TRUE );
- // The encoded string does not contain any header/footer
- // The header/footer are usually present only in files.
- xXXEncode.SetIncludeHeaderFooter( FALSE );
- xDecoder.SetRefEncodingFormat( xXXEncode.m_lpDispatch );
- break;
- }
-
- case emBase64 :
- {
- DXceedBase64EncodingFormat xBase64;
-
- if( !xBase64.CreateDispatch( "Xceed.Base64Encoding", pEx ) )
- {
- throw pEx;
- }
-
- xBase64.SetContinueOnInvalidData( TRUE );
- xDecoder.SetRefEncodingFormat( xBase64.m_lpDispatch );
- break;
- }
-
- case emHexadecimal :
- {
- DXceedHexaEncodingFormat xHexa;
-
- if( !xHexa.CreateDispatch( "Xceed.HexaEncoding", pEx ) )
- {
- throw pEx;
- }
-
- xHexa.SetContinueOnInvalidData( TRUE );
- xDecoder.SetRefEncodingFormat( xHexa.m_lpDispatch );
- break;
- }
-
- case emQuoted :
- {
- DXceedQuotedPrintableEncodingFormat xQuoted;
-
- if( !xQuoted.CreateDispatch( "Xceed.QuotedPrintableEncoding", pEx ) )
- {
- throw pEx;
- }
-
- xQuoted.SetContinueOnInvalidData( TRUE );
- xDecoder.SetRefEncodingFormat( xQuoted.m_lpDispatch );
- break;
- }
-
- case emBinHex :
- {
- DXceedBinHexEncodingFormat xBinHex;
-
- if( !xBinHex.CreateDispatch( "Xceed.BinHexEncoding", pEx ) )
- {
- throw pEx;
- }
-
- xBinHex.SetContinueOnInvalidData( TRUE );
- // The encoded string does not contain any formating
- // The formating are usually present only in files.
- xBinHex.SetIncludeHeaderFooter( FALSE );
- xDecoder.SetRefEncodingFormat( xBinHex.m_lpDispatch );
- break;
- }
- }
-
- pEx->Delete();
- }
- }
-