技术标签: Windows
1. BOM标记
UTF-8 数据头标记: EF, BB, BF
UNICODE : FF, FE
网络上传送的UTF-8数据需要偏移(EF,BB,BF)这三个字节后面的数据直接当字符串处理即可,无需转为ASCII码,否则转码ASCII码数据的第一个字节变为了'?'.
转换函数如下:
#include<string>
#include<windows.h>
#include<vector>
using namespace std;
//utf8 转 Unicode
std::wstring Utf82Unicode(const std::string& utf8string)
{
int widesize = ::MultiByteToWideChar(CP_UTF8, 0, utf8string.c_str(), -1, NULL, 0);
if (widesize == ERROR_NO_UNICODE_TRANSLATION)
{
throw std::exception("Invalid UTF-8 sequence.");
}
if (widesize == 0)
{
throw std::exception("Error in conversion.");
}
std::vector<wchar_t> resultstring(widesize);
int convresult = ::MultiByteToWideChar(CP_UTF8, 0, utf8string.c_str(), -1, &resultstring[0], widesize);
if (convresult != widesize)
{
throw std::exception("La falla!");
}
return std::wstring(&resultstring[0]);
}
//unicode 转为 ascii
std::string WideByte2Acsi(std::wstring& wstrcode)
{
int asciisize = ::WideCharToMultiByte(CP_OEMCP, 0, wstrcode.c_str(), -1, NULL, 0, NULL, NULL);
if (asciisize == ERROR_NO_UNICODE_TRANSLATION)
{
throw std::exception("Invalid UTF-8 sequence.");
}
if (asciisize == 0)
{
throw std::exception("Error in conversion.");
}
std::vector<char> resultstring(asciisize);
int convresult =::WideCharToMultiByte(CP_OEMCP, 0, wstrcode.c_str(), -1, &resultstring[0], asciisize, NULL, NULL);
if (convresult != asciisize)
{
throw std::exception("La falla!");
}
return std::string(&resultstring[0]);
}
//utf-8 转 ascii
std::string UTF_82ASCII(std::string& strUtf8Code)
{
std::string strRet("");
//先把 utf8 转为 unicode
std::wstring wstr = Utf82Unicode(strUtf8Code);
//最后把 unicode 转为 ascii
strRet = WideByte2Acsi(wstr);
return strRet;
}
///
//ascii 转 Unicode
std::wstring Acsi2WideByte(std::string& strascii)
{
int widesize = MultiByteToWideChar (CP_ACP, 0, (char*)strascii.c_str(), -1, NULL, 0);
if (widesize == ERROR_NO_UNICODE_TRANSLATION)
{
throw std::exception("Invalid UTF-8 sequence.");
}
if (widesize == 0)
{
throw std::exception("Error in conversion.");
}
std::vector<wchar_t> resultstring(widesize);
int convresult = MultiByteToWideChar (CP_ACP, 0, (char*)strascii.c_str(), -1, &resultstring[0], widesize);
if (convresult != widesize)
{
throw std::exception("La falla!");
}
return std::wstring(&resultstring[0]);
}
//Unicode 转 Utf8
std::string Unicode2Utf8(const std::wstring& widestring)
{
int utf8size = ::WideCharToMultiByte(CP_UTF8, 0, widestring.c_str(), -1, NULL, 0, NULL, NULL);
if (utf8size == 0)
{
throw std::exception("Error in conversion.");
}
std::vector<char> resultstring(utf8size);
int convresult = ::WideCharToMultiByte(CP_UTF8, 0, widestring.c_str(), -1, &resultstring[0], utf8size, NULL, NULL);
if (convresult != utf8size)
{
throw std::exception("La falla!");
}
return std::string(&resultstring[0]);
}
//ascii 转 Utf8
std::string ASCII2UTF_8(std::string& strAsciiCode)
{
std::string strRet("");
//先把 ascii 转为 unicode
std::wstring wstr = Acsi2WideByte(strAsciiCode);
//最后把 unicode 转为 utf8
strRet = Unicode2Utf8(wstr);
return strRet;
}
文章浏览阅读1.7k次。一 apache的安装和配置首先下载apche的windows操作系统的安装包https://httpd.apache.org/点击前往windows安装包的下载页面继续前往下一步下载安装包解压到自己电脑上,注意路径上不要有空格或者中文,解压产生了一个Apache24文件夹和一个html文件配置httpd.conf配置文件,找到conf目录下的httpd.conf,找到其中的Define SRVROOT,将双引号中的路径修改为刚才自己安装的apache的绝对路径原来的路径修改后_如何确定电脑apache已经安装
文章浏览阅读533次,点赞2次,收藏8次。1、管理员后台技术:Web前端使用vue框架进行开发后端使用java springboot框架进行开发数据库使用的是myql2、小程序用户端的技术:微信开发者语言:js+json+wxss+wxml3、项目整体采用的是mvc的思想模式进行开发。代码可读性高,便于理解。_招聘小程序功能框架
文章浏览阅读1.2k次。文章转载自:https://www.cnblogs.com/nxld/p/6059603.html分析数据要做的第一件事情,就是观察它。对于每个变量,哪些值是最常见的?值域是大是小?是否有异常观测?ggplot2图形之基本语法:ggplot2的核心理念是将绘图与数据分离,数据相关的绘图与数据无关的绘图分离ggplot2是按图层作图ggplot2保有命令式作图的调整函数,使其更具灵活..._下面关于ggplot2中,叙述错误的是a.ggplot2必须在rstidio平台上运行b.ggplot2
文章浏览阅读9.7k次,点赞7次,收藏116次。为单眼,单眼+惯性,立体视觉,立体+惯性和RGB-D构建节点环境为:ROS Melodic 和 Ubuntu 18.04编译1、将源码中的 Examples/ROS/ORB_SLAM3 路径添加到ROS_PACKAGE_PATH环境变量中打开 .bashrc file:gedit ~/.bashrc把下面这行加到最下面一行,把“PATH”换成你放ORB_SLAM3的路径export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:“PATH”/ORB_SLAM3/_orbslam3 ros
文章浏览阅读43次。1、带or的sqlunionunion all2、where中带max()的sqlnot exists
文章浏览阅读720次。同学们应该要知道云南专升本计算机专业考试科目是哪些,毕竟关系到未来考试,根据公布的云南专升本政策来看云南专升本计算机专业考试科目是高等数学和公共英语和数据结构,下面跟随易学仕专升本网来看看吧!一、云南专升本可以报考哪些学校?云南可以报考的院校有很多,下面就和易学仕一起来看看云南专升本学校名单有哪些吧!云南师范大学,云南艺术学院,云南民族大学,西南林业大学,云南农业大学,昆明理工大学,楚雄师范学院,..._云南专升本数据结构是考什么
文章浏览阅读1.4k次。canvas是H5的一大重点我们来学一下如何用canvas画圆画圆arc(x,y,r,起始弧度,结束弧度,顺逆时针)x,y就是这个圆的圆心坐标r是圆的半径弧度单位用Math.PI顺逆时针用0(顺时针) 1(逆时针)const cas = document.getElementsByTagName('canvas')[0];const ctx = cas.getContext("2d");ctx.arc(250,250,100,0,Math.PI / 2,1);ctx.stroke_canvas 绘制圆角的梯形图
文章浏览阅读8.1k次,点赞2次,收藏2次。1. 找到文件2. 设置添加后:_访问minio图片 直接get不显示图片
文章浏览阅读816次。MVVM 更改触发器触发事件,对没有Command的控件进行更改,将需要使用的函数定义到ViewModel中引用:如果没有这个包,就到Nuget包下载管理下载一个,之后引用即可 xmlns:i="http://schemas.microsoft.com/expression/View:这里我以TextBox为例,使用Template部分自己定义即可,直接在下方定义Interaction.Tiggers即可,(重要:EventName一定要使用本身有的API名,不要自己定义,不然可能会失效,Comma_wpf mvvm 事件触发
文章浏览阅读204次。数据导入:功能:批量把数据内容存储到数据库的表里基本用法:load data infile "目录名/文件名“fields terminated by "分隔符“lines terminated by “\n” 这里\n是换行符注意事项:字段分隔符要与文件内的一致指定导入文件的绝对路径导入数据的表字段类型要与文件字段匹配禁用selinux保护机制实例:1. 查看MySQL允许导入导出文件存放路径mysql root@localhost:(none)> s_mysql /var/lib/mysql/file/
文章浏览阅读5.5w次,点赞28次,收藏248次。sklearn.svm.SVR(kernel ='rbf',degree = 3,gamma ='auto_deprecated',coef0 = 0.0,tol = 0.001,C = 1.0,epsilon = 0.1,shrinking = True,cache_size = 200,verbose = False,max_iter = -1 )参数: kernel : ..._sklearn svr 参数
文章浏览阅读627次。七、字符串函数1. 字符串长度函数:length 语法: length(string A) 返回值: int 说明:返回字符串A的长度 举例: hive> select length('abcedfg') from lxw_dual; 72. 字符串反转函数:reverse 语法: reverse(string A) 返回值: string 说明:返回字符串A的反转结果 举例: hive&g..._hive sql 字符串运算