⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlgunicodechange.cpp

📁 串口收发工具
💻 CPP
字号:
// DlgUnicodeChange.cpp : implementation file
//

#include "stdafx.h"
#include "maintain.h"
#include "DlgUnicodeChange.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlgUnicodeChange dialog


CDlgUnicodeChange::CDlgUnicodeChange(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgUnicodeChange::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgUnicodeChange)
	m_Ansi = _T("");
	m_Unicode = _T("");
	//}}AFX_DATA_INIT
}


void CDlgUnicodeChange::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgUnicodeChange)
	DDX_Text(pDX, IDC_EDIT_ANSI, m_Ansi);
	DDX_Text(pDX, IDC_EDIT_UNICODE, m_Unicode);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgUnicodeChange, CDialog)
	//{{AFX_MSG_MAP(CDlgUnicodeChange)
	ON_BN_CLICKED(IDC_CONVERT, OnConvert)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgUnicodeChange message handlers

void CDlgUnicodeChange::OnConvert() 
{
	((CEdit*)GetDlgItem(IDC_EDIT_UNICODE))->SetWindowText("");
	UpdateData(true);
	int nCount = m_Ansi.GetLength();
	//nCount /= 2;
	WCHAR *unicodearray;
	unicodearray = new WCHAR[nCount];
	memset(unicodearray,0,nCount);
	int rtn = MultiByteToWideChar(CP_OEMCP,MB_COMPOSITE,m_Ansi.GetBuffer(nCount),nCount,unicodearray,nCount);
	CString strTemp;
	BYTE buf1,buf2;
	for(int i=0;i<nCount;i++)
	{
		buf2 = LOBYTE(unicodearray[i]);
		buf1 = HIBYTE(unicodearray[i]);
		if ((buf1==0xcd)||(buf2==0xcd))
			break;
		if (buf1<16) 
			strTemp.Format("0%X ",buf1);
		else 
			strTemp.Format("%2X ",buf1);
		m_Unicode += strTemp;
		
		if (buf2<16) 
			strTemp.Format("0%X ",buf2);
		else
			strTemp.Format("%2X ",buf2);
		m_Unicode += strTemp;
	}
	delete []unicodearray;
	UpdateData(false);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -