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_charset, char *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==0) return -1;
if (iconv(cd,pin,&inlen,pout,&outlen)==(size_t)-1) return -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);
      }

Code UTF-8 Console GB2312 Linux 中文乱码的更多相关文章

  1. Linux中文乱码问题终极解决方法

    方法一: 修改/root/.bash_profile文件,增加export LANG=zh_CN.GB18030该文件在用户目录下,对于其他用户,也必须相应修改该文件. 使用该方法时putty能显示中 ...

  2. Arch Linux中文乱码解决

    Arch Linux中文乱码解决 1.安装中文字体 pacman -S wqy-zenhei ttf-fireflysung (flash乱码)   ---乱码的原因就是缺少中文字体的支持,下载文泉驿 ...

  3. linux 中文乱码解决办法

    就是从数据库中取出来时,在存入linux的文件里时,在字符流时制定编码格式.代码如下: FileOutputStream fos=new FileOutputStream(new File(fileP ...

  4. linux中文乱码问题及locale详解

    一.修改系统默认语言及中文乱码问题记录系统默认使用语言的文件是/etc/sysconfig/i18n,如果默认安装的是中文的系统,i18n的内容如下: LANG="zh_CN.UTF-8&q ...

  5. Linux 中文乱码

    开发中不免会接触到linux,Linux系统中文语言乱码也是我们常碰到的一个问题之一. 在网上查找了不少资料,参考了https://www.linuxidc.com/Linux/2017-07/145 ...

  6. 解决mssql for linux 中文乱码问题

    什么叫一波未平一波又起,这就是,好不容易安装完成了,在用的时候居然出现了乱码,很是头疼,但还是解决了这个蛋疼的问题,在windows中使用mssql这么久,从来没出现过中文乱码的情况,具体原因是出现在 ...

  7. 在visual studio code 中配置python以及解决中文乱码问题

    安装好 visual stuido code (下面简称 “ VSC ”)后,要想使用它运行调试 python 代码还需要做一些工作以解决下列问题: 搭建 python 环境 print 打印中文出现 ...

  8. 关于解决Mac使用docker安装SQL server for Linux 中文乱码问题

    本人是Mac的追随者,无奈本学期数据库课要求使用Microsoft的SQL server.但是Microsoft并没有发布SQL server for Mac ,笔者使用Google搜索后, 发现可以 ...

  9. kaili linux中文乱码

    install kaili 用了kali,安装的英文版,一切都很爽,没有乱码 install chrome 不要用apt安装,也不要用chromium, 直接去网上找chrom的deb文件下来安装,注 ...

  10. linux中文乱码

    txt文件在linux环境下打开呈现了乱码状态. 解决方法1:在linux用iconv命令,如乱码文件名为zhongwen.txt,那么在终端输入如下命令: iconv -f gbk -t utf8 ...

随机推荐

  1. 新建zabbix数据库

    1.安装mysqldnf install -y @mysqlsystemctl start mysqld.servicesystemctl enable mysqld.service初始化mysqlm ...

  2. mybatis-关联查询3-自关联查询

    一对多的方式处理 查询指定栏目的所有子孙栏目 查询指定栏目及其所有子孙栏目 多对 一的方式处理

  3. springboot配置文件中的基本配置

    #应用启动端口设置server.port=9088#=================================微信相关====================================# ...

  4. CSS3选择器nth-child(n)

    CSS3选择器nth-child(n)实现隔几行选择元素 nth-child(n),n 可以是数字.关键词或公式.选择器匹配属于其父元素的第N个子元素,不论元素的类型. 序号写法:li:nth-chi ...

  5. GSON 特殊类型支持序列化和反序列化,如LocalDateTime

    GSON 特殊类型支持序列化和反序列化,如LocalDateTime DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern ...

  6. 时间序列 data_range()

    pd.date_range( start=None,#开始时间 end=None,#截止时间 periods=None,#总长度 freq=None,#时间间隔 tz=None,#时区 normali ...

  7. Android 将函数放到主线程运行

    有时候,app会检测加密函数是否在主线程运行,为了逃避这种检测,要将函数放到主线程运行 Class<?> aClass = RposedHelpers.findClass("co ...

  8. centos删除安装vsftpd

    准备工作 1.centos 卸载vsftpd 删除原有的vsftpd(卸载前先关闭 vsftpd: systemctl stop vsftpd)[root@localhost ~]# rpm -aq ...

  9. MySQL经典45题

    一.数据库字段说明 1.学生表 Student(SId,Sname,Sage,Ssex)SId :学生编号Sname:学生姓名Sage :出生年月Ssex:学生性别 2.课程表 Course(CId, ...

  10. 打车起步价8元(3KM以内) 超过3KM,超出的每公里1.2元 超过5KM,超出的每公里1.5元 请在键盘上接收公里数,得出总价。

    import java.util.Scanner; public class Taxi { public static void main(String []agrs){ Scanner s = ne ...