📄 unicode_testdlg.cpp
字号:
// Unicode_testDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Unicode_test.h"
#include "Unicode_testDlg.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()
/////////////////////////////////////////////////////////////////////////////
// CUnicode_testDlg dialog
CUnicode_testDlg::CUnicode_testDlg(CWnd* pParent /*=NULL*/)
: CDialog(CUnicode_testDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CUnicode_testDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CUnicode_testDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUnicode_testDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUnicode_testDlg, CDialog)
//{{AFX_MSG_MAP(CUnicode_testDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUnicode_testDlg message handlers
BOOL CUnicode_testDlg::OnInitDialog()
{
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
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CUnicode_testDlg::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 CUnicode_testDlg::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 CUnicode_testDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
//CP_ACP
void WirteHZKFile(unsigned char* buf, int len, FILE* fp)
{
fprintf(fp, "%s\n", buf);
fflush(fp);
}
#define filename "GBKConvertTableUnicode.c"
//#define filename "allgbk.c"
void CUnicode_testDlg::OnButton1()
{
char buf[3];
char buf_unicode[3];
char out[50];
int area1 = 0, area2 = 0, num = 2;
int hz_num = 0;
char title_convert[] = "int GBKConvertTableUnicode[][2] = {";
FILE* fp;
if((fp = fopen(filename, "wb")) == NULL){
MessageBox(_T("找开文件失败"), _T("failed"), 0);
return;
}
memset(buf, 0, 3);
memset(buf_unicode, 0, 3);
// 2005-8-21 23:33:36
// for(area1 = 0xa1; area1 < 0xf8; area1++){
// buf[0] = area1;
// for(area2 = 0xa1; area2 < 0xff; area2++){
// buf[1] = area2;
// buf[2] = 0x0;
// MultiByteToWideChar(936, 0, buf, strlen(buf), (unsigned short *)buf_unicode, num);
// sprintf(out, "{0x%02x%02x, 0x%02x%02x},/*%s*/", (unsigned char)buf[0], (unsigned char)buf[1], (unsigned char)buf_unicode[1], (unsigned char)buf_unicode[0], buf);
// ::OutputDebugStringA(out);
// ::OutputDebugStringA("\n");
// WirteHZKFile((unsigned char* )out, strlen(out), fp);
// hz_num++;
// }
// }
// 2005-8-20 10:36:15
WirteHZKFile((unsigned char* )title_convert, strlen(title_convert), fp);
for(area1 = 0xa1; area1 < 0xf8; area1++){
buf[0] = area1;
for(area2 = 0xa1; area2 < 0xff; area2++){
buf[1] = area2;
buf[2] = 0x0;
MultiByteToWideChar(936, 0, buf, strlen(buf), (unsigned short *)buf_unicode, num);
sprintf(out, "{0x%02x%02x, 0x%02x%02x},/*%s*/", (unsigned char)buf[0], (unsigned char)buf[1], (unsigned char)buf_unicode[1], (unsigned char)buf_unicode[0], buf);
::OutputDebugStringA(out);
::OutputDebugStringA("\n");
WirteHZKFile((unsigned char* )out, strlen(out), fp);
hz_num++;
}
}
WirteHZKFile((unsigned char* )"};", strlen("};"), fp);
buf[0] = 0xb0;
buf[1] = 0xa1;
buf[2] = 0x0;
//2.BIG5 to Unicode
// MultiByteToWideChar(950, 0, PChar(ABig5String), length(ABig5String), @mWString, cchWideChar);
//3.Unicode to GBK
// WideCharToMultiByte(936, 0, @mWString, cchWideChar, PChar(Result), length(Result), '?', @mLongBool);
// TODO: Add your control notification handler code here
/* 2005-08-16 16:52:14
::MessageBoxA(0, buf, 0, 0);
MessageBox(_T("啊ttt"), 0, 0);
MessageBox(_T("啊我"), 0, 0);
*/
::MessageBoxA(0, "完成转换", "完成", 0);
fclose(fp);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -