当前位置: 首页 > news >正文

常德农科院网站一份完整的品牌策划方案

常德农科院网站,一份完整的品牌策划方案,网站制作的预算,wordpress页面id文章目录 字符编码问题编码转换问题ANSI转UnicodeUnicode转ANSIUtf8转 ANSIutf8 转UnicodeANSI 转UTF-8Unicode 转 UTF-8 全部代码 字符编码问题 Windows API 函数 MessageBoxA:MessageBox 内部实现,字符串编码(ANSI)转换成了Unicode,在调用MessageboxW MessageBox:…

文章目录

  • 字符编码问题
  • 编码转换问题
    • ANSI转Unicode
    • Unicode转ANSI
    • Utf8转 ANSI
    • utf8 转Unicode
    • ANSI 转UTF-8
    • Unicode 转 UTF-8
  • 全部代码

字符编码问题

在这里插入图片描述

Windows API 函数
MessageBoxA:MessageBox 内部实现,字符串编码(ANSI)转换成了Unicode,在调用MessageboxW
MessageBox:是一个宏定义
MessageBoxA(NULL,"Hello","提示",MB_OK);
MessageBoxW(NULL,L"Hello",L"提示",MB_OK);

编码转换问题

ANSI转Unicode

//ANSI转Unicode
wchar_t* CCharset::AnsiToUnicode(const char* str)
{if (m_wstr)//安全{delete m_wstr;m_wstr = NULL;}DWORD dwSize=::MultiByteToWideChar(CP_ACP,0,str,-1,NULL,0);//求宽字符的大小m_wstr = new wchar_t[dwSize];::MultiByteToWideChar(CP_ACP, 0, str, -1, m_wstr, dwSize);return m_wstr;
}

Unicode转ANSI

//Unicode转ANSI
char * CCharset::UnicodeToAnsi(const wchar_t * wstr)
{if (m_str){delete m_str;m_str = NULL;}DWORD dwSize=WideCharToMultiByte(CP_ACP, 0, wstr, -1,NULL,0,NULL,NULL);m_str = new char[dwSize];::WideCharToMultiByte(CP_ACP, 0, wstr, -1, m_str, dwSize, NULL, NULL);return m_str;
}

Utf8转 ANSI

char * CCharset::Utf8ToAnsi(const char * str)
{if (m_wstr){delete[] m_wstr;m_wstr = NULL;}if (m_str){delete[] m_str;m_str = NULL;}//UTF-8 转Unicodem_wstr= Utf8ToUnicode(str);//Unicode 转ANSIm_str= UnicodeToAnsi(m_wstr);return m_str;
}

utf8 转Unicode

wchar_t* CCharset::Utf8ToUnicode(const char * str)
{if (m_wstr){delete m_wstr;m_wstr = NULL;}DWORD dwSize=MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);m_wstr = new wchar_t[dwSize];memset(m_wstr, 0, dwSize*sizeof(wchar_t));//清空内存MultiByteToWideChar(CP_UTF8, 0, str, -1, m_wstr, dwSize);return m_wstr;
}

ANSI 转UTF-8

char* CCharset::AnsitoUtf8(const char* str)
{if (m_wstr){delete[] m_wstr;m_wstr = NULL;}if (m_utf8){delete[] m_utf8;m_utf8 = NULL;}//Ansi 转Unicodem_wstr= AnsiToUnicode(str);//Unicode 转UTF-8m_utf8=UnicodeToUtf8(m_wstr);return m_utf8;
}

Unicode 转 UTF-8

char * CCharset::UnicodeToUtf8(const wchar_t * wstr)
{if (m_utf8){delete[] m_utf8;m_utf8 = NULL;}DWORD dwSize=WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);m_utf8 = new char[dwSize];memset(m_utf8,0,dwSize);//清空内存WideCharToMultiByte(CP_UTF8, 0, wstr, -1, m_utf8, dwSize, NULL, NULL);return m_utf8;
}

全部代码

CCharset.h

#pragma once
class CCharset
{private:wchar_t* m_wstr;char* m_str;char* m_utf8;
public:CCharset();~CCharset();//ANSI转Unicodewchar_t* AnsiToUnicode(const char* str);//Unicode转ANSIchar* UnicodeToAnsi(const wchar_t* wstr);//UTF8 转ANSIchar* Utf8ToAnsi(const char* str);//ANSI转UTF - 8char* AnsitoUtf8(const char* str);//Unicode 转 UTF-8char* UnicodeToUtf8(const wchar_t* wstr);//UTF-8转Unicodewchar_t* Utf8ToUnicode(const char* str);};

CCharset.cpp

#include "pch.h"
#include "CCharset.h"CCharset::CCharset()
{m_wstr = NULL;m_str = NULL;m_utf8 = NULL;
}CCharset::~CCharset()
{if (m_wstr){delete m_wstr;m_wstr = NULL;}if (m_str){delete m_str;m_str = NULL;}if (m_utf8){delete[] m_utf8;m_utf8 = NULL;}
}//ANSI转Unicode
wchar_t* CCharset::AnsiToUnicode(const char* str)
{if (m_wstr)//安全{delete[] m_wstr;m_wstr = NULL;}DWORD dwSize=::MultiByteToWideChar(CP_ACP,0,str,-1,NULL,0);//求宽字符的大小m_wstr = new wchar_t[dwSize];::MultiByteToWideChar(CP_ACP, 0, str, -1, m_wstr, dwSize);return m_wstr;
}//Unicode转ANSI
char * CCharset::UnicodeToAnsi(const wchar_t * wstr)
{if (m_str){delete[] m_str;m_str = NULL;}DWORD dwSize=WideCharToMultiByte(CP_ACP, 0, wstr, -1,NULL,0,NULL,NULL);//求字符的大小m_str = new char[dwSize];::WideCharToMultiByte(CP_ACP, 0, wstr, -1, m_str, dwSize, NULL, NULL);return m_str;
}char * CCharset::Utf8ToAnsi(const char * str)
{if (m_wstr){delete[] m_wstr;m_wstr = NULL;}if (m_str){delete[] m_str;m_str = NULL;}//UTF-8 转Unicodem_wstr= Utf8ToUnicode(str);//Unicode 转ANSIm_str= UnicodeToAnsi(m_wstr);return m_str;
}char* CCharset::AnsitoUtf8(const char* str)
{if (m_wstr){delete[] m_wstr;m_wstr = NULL;}if (m_utf8){delete[] m_utf8;m_utf8 = NULL;}//Ansi 转Unicodem_wstr= AnsiToUnicode(str);//Unicode 转UTF-8m_utf8=UnicodeToUtf8(m_wstr);return m_utf8;
}//Unicode 转 UTF-8
char * CCharset::UnicodeToUtf8(const wchar_t * wstr)
{if (m_utf8){delete[] m_utf8;m_utf8 = NULL;}DWORD dwSize=WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);m_utf8 = new char[dwSize];memset(m_utf8,0,dwSize);//清空内存WideCharToMultiByte(CP_UTF8, 0, wstr, -1, m_utf8, dwSize, NULL, NULL);return m_utf8;
}//utf8 转Unicode
wchar_t* CCharset::Utf8ToUnicode(const char * str)
{if (m_wstr){delete m_wstr;m_wstr = NULL;}DWORD dwSize=MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);m_wstr = new wchar_t[dwSize];memset(m_wstr, 0, dwSize*sizeof(wchar_t));//清空内存MultiByteToWideChar(CP_UTF8, 0, str, -1, m_wstr, dwSize);return m_wstr;
}
http://www.wangmingla.cn/news/66675.html

相关文章:

  • 苍南网站建设公司重庆seo研究中心
  • 网上创建公司seo和sem哪个工资高
  • wordpress 网站怎么优化推广
  • 常德网站建设求职简历百度公司总部在哪里
  • 网店运营实训总结seo如何建立优化网站
  • 我想做个网站怎么做的合肥网络推广软件
  • 网站建设教学大纲鄂州网站seo
  • 如何做原创漫画网站电商大数据查询平台免费
  • 河南建网站打开百度一下
  • java做直播网站有哪些广告商对接平台
  • 怎么开微商城网店步骤seo百度快速排名
  • 用java做网络小说网站杭州正规引流推广公司
  • 性是怎么做视频网站合肥网站seo费用
  • 动漫设计与制作专业的应用领域seo网站推广是什么
  • 东莞浩智网站建设公司互联网关键词优化
  • 郑州网站建设设计公司哪家好必应搜索引擎
  • 做公司网站需要多网站内部链接优化方法
  • 私人怎么做网站b2c有哪些电商平台
  • 做网站建设哪家效益快产品网络推广
  • 上海php网站开发公司广州网站推广平台
  • 织梦软件网站模板下载百度登录账号首页
  • 做彩妆网站的公司湖南网站建设seo
  • 夜晚十大禁用直播app企业seo排名费用报价
  • 石家庄网站建设网络营销推广公司名称
  • 毕设 网站开发seo实战指导
  • 福州快速优化排名刷seo排名
  • 视频网站怎么搭建微软优化大师
  • 网站关键词分布情况seo关键词推广怎么做
  • 东莞网站优化快速排名环球网最新消息
  • wordpress前端开发整站优化系统