当前位置:网站首页>C language utf8toutf16 (UTF-8 characters are converted to hexadecimal encoding)
C language utf8toutf16 (UTF-8 characters are converted to hexadecimal encoding)
2022-07-03 11:31:00 【Ch_ champion】
summary
Application scenario SCM , Encoding mode conversion
uint8_t get_utf8_bytes(uint8_t utf8)
{
for (uint8_t i = 0; i < 6; i++) {
if ((utf8 & (0x80 >> i)) == 0) {
return i == 0? 1: i;
}
}
return 1;
}
uint16_t utf8_TO_utf16(uint8_t *in, uint16_t inLen, uint16_t *out, uint16_t outLen)
{
uint16_t length = 0;
uint8_t bytes = 0;
for (uint16_t i = 0; i < inLen && length < outLen; i++, length++) {
bytes = get_utf8_bytes(in[i]);
if (bytes > 1) {
out[length] = in[i] & (0xFF >> (bytes + 1));
for (uint8_t j = 1; j < bytes; j++) {
i++;
out[length] <<= 6;
out[length] += in[i] & 0x3F;
}
} else {
out[length] = in[i];
}
}
out[length] = 0;
return length;
}
summary
Take a note here , I'll look it up later , meanwhile , Thank you for your appreciation ^_^.
边栏推荐
- 如何成为一名高级数字 IC 设计工程师(1-2)Verilog 编码语法篇:Verilog 1995、2001、2005 标准
- MATLAB提取不规则txt文件中的数值数据(简单且实用)
- VPP three-layer network interconnection configuration
- 导师对帮助研究生顺利完成学业提出了20条劝告:第一,不要有度假休息的打算.....
- How to become a senior digital IC Design Engineer (1-2) Verilog coding syntax: Verilog 1995, 2001, 2005 standards
- POI excel cell wrap
- VPP三层网络互联配置
- Processes and threads
- Expandablelistview that can expand and shrink (imitating the list page of professional selection of Zhilian recruitment)
- FL Studio 20 unlimited trial fruit arranger Download
猜你喜欢
Kibana~Kibana的安装和配置
Use typora to draw flow chart, sequence diagram, sequence diagram, Gantt chart, etc. for detailed explanation
Gut | 香港中文大学于君组揭示吸烟改变肠道菌群并促进结直肠癌(不要吸烟)
聊聊Flink框架中的状态管理机制
(2) Base
Machine learning 3.2 decision tree model learning notes (to be supplemented)
面试题总结(2) IO模型,集合,NIO 原理,缓存穿透,击穿雪崩
Google Earth engine (GEE) - ghsl global population grid dataset 250 meter resolution
Numpy np.max和np.maximum实现relu函数
DS90UB949
随机推荐
Kibana~Kibana的安装和配置
How to clean up v$rman_ backup_ job_ Details view reports error ora-02030
C language log base zlog basic use
Google Earth engine (GEE) - ghsl global population grid dataset 250 meter resolution
[vtk] source code interpretation of vtkpolydatatoimagestencil
大厂技术专家:工程师如何提升沟通能力?
Project management essence reading notes (6)
帝国cms 无缩略图 灵动标签(e:loop)判断有无标题图片(titlepic)的两种写法
Google Earth engine (GEE) -- when we use the front and back images to make up for the interpolation effect, what if there is no effect?
asyncio 警告 DeprecationWarning: There is no current event loop
Redis things
Using activity to realize a simple inputable dialog box
表空间创建管理及控制文件管理
项目管理精华读书笔记(七)
行业唯一!法大大电子合同上榜36氪硬核科技企业
鸿蒙第四次培训
[vtk] interpretation of source code comments of vtkwindowedsincpolydatafilter
Encapsulation attempt of network request framework of retro + kotlin + MVVM
How to: configure ClickOnce trust prompt behavior
How PHP solves the problem of high concurrency