代码拉取完成,页面将自动刷新
#include "StdAfx.h"
#include "Charset.h"
#include <iostream>
CCharset::CCharset(void)
{
m_pTable = NULL;
m_nCount = 0;
}
CCharset::~CCharset(void) {}
BOOL CCharset::LoadFromFile(LPCTSTR pFileName)
{
CFile cf;
ULONG len;
if (!cf.Open(pFileName,CFile::modeRead|CFile::shareDenyNone)) {return FALSE;}
len = (ULONG)cf.GetLength();
m_pTable = (WCHAR*)malloc(len+2);
if(m_pTable==NULL) {
cf.Close();
return FALSE;
}
ZeroMemory(m_pTable,len+2);
if(cf.Read(m_pTable,len)!=len) {
cf.Close();
free(m_pTable);
m_pTable = NULL;
return FALSE;
}
cf.Close();
m_nCount = len/2;
return TRUE;
}
BOOL CCharset::CreateFromResource(LPCTSTR pString, DWORD dwSize)
{
ULONG len = dwSize;
m_pTable = (WCHAR*) malloc(len + 2);
if (!m_pTable) {return false;}
ZeroMemory(m_pTable, len + 2);
m_pTable = _wcsdup(pString);
m_nCount = len / 2;
return false;
}
BOOL CCharset::Create(LPCTSTR pString)
{
m_nCount = (UINT)wcslen(pString);
m_pTable = _wcsdup(pString);
return FALSE;
}
void CCharset::Delete()
{
free(m_pTable);
m_pTable = NULL;
m_nCount = 0;
}
WCHAR CCharset::GetChar(UINT index)
{
if(m_pTable == NULL) {return L'?';}
if(index < m_nCount) {return *(m_pTable+index);}
return L'?';
}
UINT CCharset::GetCharCount() {return m_nCount;}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。