unicode 转码 ansi
#include "stdafx.h"
#include <Windows.h>
#include <stdio.h>
HRESULT SomeCOMFunction(BSTR *bstr)
{
*bstr = ::SysAllocString(L"你好,软件测试,lenmom");
return S_OK;
}
int _tmain(int argc, _TCHAR* argv[])
{
BSTR unicodestr = 0;
char *ansistr=NULL;
SomeCOMFunction(&unicodestr);
int lenW = ::SysStringLen(unicodestr);
int lenA = ::WideCharToMultiByte(CP_ACP, 0, unicodestr, lenW, 0, 0, NULL, NULL);
if (lenA > 0)
{
ansistr = new char[lenA + 1]; // allocate a final null terminator as well
::WideCharToMultiByte(CP_ACP, 0, unicodestr, lenW, ansistr, lenA, NULL, NULL);
ansistr[lenA] = 0; // Set the null terminator yourself
FILE *fp;
if((fp = fopen("d:\\111.vbs", "wb+"))==NULL) {
printf("Cannot open file.\n");
exit(1);
}
else
{
fputs(ansistr, fp);
}
fclose(fp);
}
else
{
// handle the error
}
//...use the strings, then free their memory:
if(ansistr!=NULL)
delete[] ansistr;
::SysFreeString(unicodestr);
return 0;
}
unicode 转码 ansi的更多相关文章
- [C/C++]_[VS2010来源与UTF8中国字符串转码ANSI问题]
现场: 1.思想vs设置源文件UTF8编码,代码中国串出现在它必须是utf8编码,不幸的是,,假定源代码将出现在中国字符串,在存储器中转码ANSI编码. Unicode(UTF8签名) 代码页(650 ...
- [C/C++]_[VS2010使用源代码UTF8中国字符串转码ANSI问题]
场景: 1.思想vs设置源文件UTF8编码,的代码串中国出现在它必须是utf8编码.不幸的是没有,假设源代码出现在中国字符串,在内存公交码ANSI编码. Unicode(UTF8) 代码页(65001 ...
- IDEA Properties中文unicode转码问题
在IDEA中创建了properties文件,发现默认中文不会自动进行unicode转码.如下 在project settings - File Encoding,在标红的选项上打上勾,确定即可 效果图 ...
- jmeter接口测试--响应结果Unicode转码成中文
jmeter接口测试-响应结果Unicode转码成中文 一般情况下,接口返回数据都会经过加密,所以有时相应结果会显示为Unicode,因此,需添加BeanShell PostProcessor,加入代 ...
- 前端Unicode转码的好处
站长工具支持Unicode转码:http://tool.chinaz.com/Tools/Unicode.aspx (这是一个网页标题)转码后 ------>变为:\u8fd9\u662f\u4 ...
- 编码知识梳理(UTF-8, Unicode, GBK, X509, ANSI, VIM中编码)
编码小结 1 初识编码 所谓编码,是信息从一种形式或格式转换为另一种形式的过程. 字符编码,从自然语言的字符的一个集合(如字母表或音节表),到其他东西的一个集合(如号码或电脉冲)的映射 ANSI:wi ...
- [编码]ASCII、GBK、Unicode(万国码) 和 UTF-8
American ASCII编码 (American Standard Code for Information Interchange,美国信息互换标准代码) China gbk编码 ...
- Unicode, UTF, ASCII, ANSI format differences
Going down your list: "Unicode" isn't an encoding, although unfortunately, a lot of docume ...
- php 解决json_encode中文UNICODE转码问题
用PHP的json_encode来处理中文的时候, 中文都会被编码, 变成不可读的, 类似"\u***"的格式,如果想汉字不进行转码,这里提供三种方法 1.升级PHP,在PHP5. ...
随机推荐
- Redis学习第四课:Redis List类型及操作
list是一个链表结构,主要功能是push.pop.获取一个范围的所有值等,操作中key理解为链表的名字. Redis的list类型其实就是一个每个子元素都是string类型的双向链表.我们可以通过p ...
- django中的ajax组件
目录 django中的ajax 向服务器发送请求的途径 Ajax的特点 基于jquery实现的ajax请求 利用ajax实现计算器 利用ajax实现登陆认证 利用form表单进行文件上传 利用ajax ...
- JS禁止用F5键
//禁止用F5键 function document.onkeydown() { if ( event.keyCode==116) { event.keyCode = 0; event.cancelB ...
- [LeetCode&Python] Problem 821. Shortest Distance to a Character
Given a string S and a character C, return an array of integers representing the shortest distance f ...
- Laravel学习之旅(三)
视图 一.怎么新建视图: 1.视图默认存放路径:resources/views: 2.laravel模板支持原生的PHP,直接可以在resources/views新建一个PHP文件,例如: index ...
- HPU 1437: 王小二的求值问题
1437: 王小二的求值问题 时间限制: 1 Sec 内存限制: 128 MB提交: 141 解决: 31 统计 题目描述 题意超级简单,求一个序列的次大值. 输入 多组输入,每个测试实例占两行,包括 ...
- 使用pip install XX 命令时报错
在使用pip命令安装的时候,我遇到这样的报错: C:\Users\86962>pip install Appium-Python-Client Collecting Appium-Python- ...
- Nginx 安装成Windows 服务方法
1. 下载nginx windows版本 http://www.nginx.org 2. 下载微软的2个工具: instsrv.exe.srvany.exe 去微软网站下载安装Windows Serv ...
- php递归函数return会出现无法正确返回想要值的情况
php递归函数中使用return的时候会碰到无法正确返回想要的值得情况,如果不明白其中的原因,很难找出错误的,就下面的具体例子来说明一下吧: 1 2 3 4 5 6 7 8 9 function te ...
- 为什么有时候 php 没有写闭合标签结束符?
找了一些资料,大家对PHP闭合标签的总结如下: 好处:如果这个是一个被别人包含的程序,没有这个结束符,可以减少很多很多问题,比如说:header, setcookie, session_start这些 ...