惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
The Register - Security
The Register - Security
Stack Overflow Blog
Stack Overflow Blog
博客园 - 三生石上(FineUI控件)
T
Threat Research - Cisco Blogs
S
SegmentFault 最新的问题
V2EX - 技术
V2EX - 技术
Hacker News: Ask HN
Hacker News: Ask HN
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Proofpoint News Feed
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
B
Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
C
Cybersecurity and Infrastructure Security Agency CISA
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
U
Unit 42
腾讯CDC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
H
Help Net Security
Recent Announcements
Recent Announcements
P
Privacy & Cybersecurity Law Blog
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 热门话题
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Heimdal Security Blog
博客园 - 聂微东
S
Securelist
大猫的无限游戏
大猫的无限游戏
Cloudbric
Cloudbric
Cisco Talos Blog
Cisco Talos Blog

博客园 - DotNet1010

.NET 6 的 docker 镜像可以有多小 穿透式监管与CTP swagger 兼容 docker 转发 配置 rust 条件编译 Debug Release rust-must-know-crates-5ad8 100DayOfRust python C# DES 加密转换 The Little Book of Rust Books .NET 5 WPF 配置文件变动 程序自动刷新 (reloadOnChange) C# 高精度定时器 NET number values such as positive and negative infinity cannot be written as valid JSON C# 各种序列化方案比较 Python3 HDF5 中英文混合存储 MVVM WPF 简化 类的开发 websocket-per-message-compression Asp.net Core WebSocket 支持压缩 Redis 监控工具 期货行情查看客户端下载 完美解决windows10磁盘占用100%并出现卡顿、假死无反应 How to disable the unused macros warning? --rust 看阿里架构师是如何在高并发的情景下运筹帷幄
Code UTF-8 Console GB2312 Linux 中文乱码
DotNet1010 · 2021-06-04 · via 博客园 - DotNet1010

Posted on 2021-06-04 17:36  DotNet1010  阅读(153)  评论()    收藏  举报

Linux 系统方法:  LD_LIBRARY_PATH=. ./userdemo | iconv -f GB2312 -t utf8   

Shell 方法  Shell 编码 改成GB2312

// 编码转换

//https://www.cnblogs.com/Ivanhan2019/p/11633247.html

int code_convert(const  char *from_charset,const  char *to_charsetchar *inbuf,size_t inlen,char *outbuf,size_t outlen)

{

iconv_t cd;

//int rc;

char **pin = &inbuf;

char **pout = &outbuf;

cd = iconv_open(to_charset,from_charset);

if (cd==0return -1;

if (iconv(cd,pin,&inlen,pout,&outlen)==(size_t)-1return -1

iconv_close(cd);

return 0;

}

// utf8码转为GB2312码

int u2g(char *inbuf,int inlen,char *outbuf,int outlen)

{

return code_convert("utf-8",  "gb2312",inbuf,inlen,outbuf,outlen);

}

// GB2312码转为utf8

int g2u(char *inbuf,size_t inlen,char *outbuf,size_t outlen)

{

   return code_convert("gb2312","utf-8",inbuf,inlen,outbuf,outlen);

}

// utf8转为gbk

string u2a(const char *inbuf)

{

int inlen=strlen(inbuf);

string strRet;

strRet.resize(inlen*2+2);

if(code_convert("utf-8","gbk",const_cast<char *>(inbuf),inlen,&strRet[0],strRet.size()))

return inbuf;

return strRet;

}

// gbk转为utf8

string a2u(const char *inbuf)

{

int inlen=strlen(inbuf);

string strRet;

strRet.resize(inlen*2+2);

if(code_convert("gbk","utf-8",const_cast<char *>(inbuf),inlen,&strRet[0],strRet.size()))

return inbuf;

return strRet;

}

  int char_length=255;   char out1[char_length];

      if(g2u(pRspInfo->ErrorMsg,strlen(pRspInfo->ErrorMsg),out1,char_length)!=-1)

      {

             strcpy(pRspInfo->ErrorMsg,out1);

             //{OnRspOrderAction} Fail ErrorID:1172, ErrorMsg:该报单不存在 nRequestID:1 Chain:1

             PRINT_RSP_ERR(pRspInfo);

      }