怎样使用CHttpFile读取Unicode编码的网页

WinInet编程:CHttpFile获取请求头信息注意的几个问题             最近,在进行Http协议下的WinInet编程,出现了不少问题。自己在解决这些问题的同时,觉得有必要将一些问题与大家分享一下。这里讲一下CHttpFile获取请求头信息要注意的几个问题。             用MFC的WinInet封装类编程,如果想要获取请求头信息,按MSDN的说法是:在CHttpFile对象成功调用SendRequest函数后,再调用Quer 阅读详情

 如果使用CHttpFile的ReadString方法读取Unicode编码的网页,结果是读出的数据不正确,感觉是ReadString方法在Unicode下实现错误,因此只能使用Read方法。

  const int size = 1024;
  byte pByte[size];
  SecureZeroMemory(pByte,size);
  int count = 0;
  vector<byte> vecByte;
  CString strUpdateInfo;
  while( ( count = pFile->Read(pByte,size) ) > 0 )
  {
   for(int i = 0; i < count; ++i)
   {
    vecByte.push_back(pByte[i]);
   }
   SecureZeroMemory(pByte,size);
   if( count < size )
    break;
  }

  if( vecByte.size() > 0 )
  {
   byte * pB = new byte[vecByte.size()];
   copy(vecByte.begin(),vecByte.end(),pB);

   TCHAR * pChr = (TCHAR*)pB;

   strUpdateInfo = pChr;

   delete [] pB;
  }
  else
  {
   strUpdateInfo = _T("");
  }

MFC实现HTTP文件下载指南 MFC(Microsoft Foundation Classes)是一个用于简化Windows应用程序开发的C++库。它提供了一组封装了Windows API的类,这些类使得创建用户界面、处理输入输出以及管理应用程序资源变得更加容易。MFC被设计为一个对象框架,允许开发者利用面向对象的方法来构建应用程序。 阅读详情

相关推荐

C++使用 CHttpFile类,实现HTTP协议下请求数据,实现HTTP协议下多文件上传!VS2013开发,可直接运行!

1:base64加密传输数据,解决宽字符,中文传输数据问题 2:模拟表单实现多类型文件上传 3:vs2013开发,完整项目上传,下载即可完整运行

C++/MFC简单实现HTTP通信(基于CHttpFile)

本例介绍一下用MFC中的CHttpFile来简单的实现Http通信,简单有效。 源码: HttpTools.h #pragma once #include <iostream> #include "afxinet.h" namespace HttpTools { enum HttpResult { HTTP_SUCCESS = 0, //成功 HTTP_FAILURE = 1, //失败 HTTP_OUTTIME = 2, //超时 }; enum Http.

r5014的博客[Eosin_Sky] 3652

告别U盘!在Ubuntu 22.04上从零搭建PXE网络装机服务器(支持UEFI/Legacy双启动)

本文详细介绍了在Ubuntu 22.04上搭建PXE网络装机服务器的完整流程,支持UEFI/Legacy双启动模式。通过配置DHCP、TFTP和HTTP服务,实现无需U盘的高效批量系统部署,解决传统安装方式的介质依赖、版本控制和时间成本问题,显著提升机房维护和设备部署效率。

weixin_42569329的博客 253

linux c http 服务端,使用CHttpFile从服务器端正确的读取数据

JVM,JAVA集合,JAVA多线程并发,JAVA基础,Spring原理,微服务,Netty与RPC,网络,日志,Zookeeper,Kafka,RabbitMQ,Hbase,MongoDB,Cassandra,设计模式,负载均衡,数据库,一致性哈希,JAVA算法,数据结构,加密算法,分布式缓存,Hadoop,Spark,Storm,YARN,机器学习,云计算…adoop,Spark,Storm,YARN,机器学习,云计算…[外链图片转存中…(img-uZ8qb2rm-1711706291791)]

2401_83973995的博客 336

基于STM32-XPC仿真平台的构架

基于STM32-XPC仿真平台的构架 xPC Target是MathWorks公司的MATLAB提供的一个基于RTW(Real-Time Workshop)体系框架的附加产品,是一种用于产品原型开发、测试和配置实时系统的PC机解决途径。xPC目标实时仿真系统能够使开发者在产品开发前进行产品原型的快速实现、测试和评估,是 Simulink 工具集下用于产品原型开发设计测试集于一体的工具箱。

sujianbonwpu的博客 4493

opencv的cmake报错

1、下载 ippicv_2021.8_win_intel64_20230330_general.zip、v0.1.2a.zip、opencv_videoio_ffmpeg.dll、opencv_videoio_ffmpeg_64.dll、ffmpeg_version.cmake。由于下载源在https://raw.githubusercontent.com,由于网络原因下载不顺畅,可以先找到文件下载到对应文件夹下,或者更改网络环境。ffmpeg_version.cmake文件,打开后显示如下, 另存即可。

nownow_的博客 1305

MFC网页访问的实现示例

使用MFC对话框,实现对http数据的访问。示例使用了CInternetSession建立连接,使用CHttpFile读取内容!实现需要包含头文件:afxinet.h

思重的专栏 2176

从零构建C++ Gerber解析器:以PCB缺陷检测为目标的实战指南

本文是一份面向PCB缺陷检测项目的实战指南,详细介绍了如何从零开始使用C++构建高性能的Gerber文件解析器。文章深入剖析了Gerber RS-274X格式,并提供了完整的开发环境搭建、核心数据结构设计、解析步骤实现以及为缺陷检测优化的具体方案,旨在帮助开发者获得对PCB制造数据的深度控制与极致性能。

weixin_29291185的博客 190

2013-1-15

// CInternetSession session; // CHttpFile *file = NULL; // //CString strURL = "http://blog.csdn.net/zbc_vc/article/details/8505509"; // // CString strURL = "http://blog.csdn.net/zbc_vc/a

zbc_vc的专栏 510

ESP32-S3 SPI驱动SD卡与FATFS文件系统实践

SPI(串行外设接口)是嵌入式系统中常用的同步串行通信协议,通过主从架构实现全双工通信。其工作原理基于时钟同步和数据线传输,具有接线简单、占用引脚少的优势。在存储扩展场景中,SPI模式可驱动SD卡实现大容量数据存储,配合FATFS文件系统可提供标准化的文件管理能力。ESP32-S3作为乐鑫推出的高性能Wi-Fi/蓝牙双模芯片,其SPI外设支持高达80MHz时钟频率,结合ESP-IDF提供的sdspi_host驱动,开发者能快速实现SD卡存储方案。该技术广泛应用于物联网设备日志存储、传感器数据采集等场景,本实

weixin_29168393的博客 367

windows使用jupyter notebook读取文件路径的几种方法和设置默认打开路径

简单分享小虎这段时间以来学到的jupyter notebook操作技巧。

狂小虎/Anthony Dave的博客 KuangXiaoHu's Blogs 1万+

MFC C++ 获取外网IP地址

#include &lt;afxinet.h&gt; //GB2312 转换成 Unicode wchar_t* GB2312ToUnicode(const char* szGBString) { UINT nCodePage = 936; //GB2312 int nLength=MultiByteToWideChar(nCodePage,0,szGBString,-...

weixin_34354173的博客 260

ACC自适应巡航系统

ACC自适应巡航系统可在高速驾驶情况下,自动控制纵向跟车距离,减轻驾驶员的工作量。该功能主要依靠安装在车辆前挡风玻璃上的摄像头和布置在格栅附近的雷达进行融合实现。

未知艺术家的博客 215

MFC利用CHttpFile类实现post数据

bool CUploadUtils::PostUploadPartFile(LPCTSTR Url, LPCTSTR sAaccess_token,std::wstring UploadName, char*& _RetStr, const std::string& _FilePath, std::wstring strLocalFileName, std::wstring wsProjId,ULONGLONG uTotalSize,int nShareCount,int nIndex)

欧特GO 1535

自学 ABAP 和自学 SAP 的差别

有朋友在我的 ABAP 学习教程里留言: > 自学SAP是不是都要搭建虚拟服务器,然后自己去官网下载新版本SAP就可以吗 对于初学者,我们要搞清楚 ABAP 和 SAP 的区别。 ABAP 是一门编程语言,SAP 首先是德国软件公司的名称,也代表这家公司开发的一系列软件。SAP 公司开发的软件,我们有时也称产品,其功能能满足客户一个或者多个领域的业务需求。这些不同领域,我们也称为不同的业务模块,比如 ERP,CRM,SRM,HR 等等。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 6882

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

MFC 下载网络文件到本地 利用 CHttpFile 和 URLDownloadToFile 【可设超时及进度】两种方式

说明 方法1较为简单,通用的多,但在某些环境下可能出现未知错误(也有可能你碰不到,反正我是碰到了)。 方法2实现相对麻烦点,但可设置超时时间以及进度展示,但要实例化一个LPBINDSTATUSCALLBACK 子类,在这个子类中去实现。这个相对好用点,方法1遇到的错误的情况,用方法2却可以正常使用。 LPBINDSTATUSCALLBACK 这个子类代码没有贴出来,放在文未,可点击下载。 ...

不经一番寒彻骨,怎得梅花扑鼻香。 4610

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

MFC web文件 CHttpFile的使用初探

MFC简单使用CHttpFile

架构师之路,举步维艰。 1031

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

使用CHttpFile从服务器端正确的读取数据

前段时间在给软件做升级提示模块的时候发现一个问题,就是使用CHttpFile对象无法从服务器端获取到正确的响应数据长度,无论是使用CHttpFile:: QueryInfo方法,还是使用CHttpFile:: GetLength方法,每次获取的长度都不固定,造成读取数据错误。万般无奈,最后只能采用动态数组的办法来解决这个问题,代码如下: #define READ_BUFFER_L...

313

MFC 上传文件函数 (利用 CHttpFile 上传 )

上传本地文件至服务器指定位置 //上传本地文件至服务器指定位置 BOOL UploadFile(LPCTSTR strURL, //负责接收上传操作的页面的URL LPCTSTR strLocalFileName) //待上传的本地文件路径 { ASSERT(strURL != NULL &amp;&amp; strLocalFileName != NULL); ...

不经一番寒彻骨,怎得梅花扑鼻香。 4180

使用CHttpFile上传下载文件(类)

源码: 头文件(HttpFileClient.h) #pragma once   #define  __BUFFER_SIZE 1024 class CHttpFile; class CHttpFileClient { public:  CHttpFileClient(void);  ~CHttpFileClient(void); public:  BOOL UploadF

langal1212的专栏 3365

php c http,c++ CHttpFile::ReadString 乱码

C++ MFC 对话框项目中抓取编码为utf-8的网页时会出现中文乱码。项目 -》属性-》 常规 中 字符集 为使用多字节字符集。找了很长时间才找到这个函数。中间过程各种苦啊,不说了下面贴代码。这一段是函数的使用:CString url;url = "https://www.badiu.com";CInternetSession session(NULL,0 );CHttpFile * ...

weixin_36361600的博客 496

VC下CHttpFile.ReadString 中文读取乱码的编码方法

//UTF-8 to GB2312 CString WebProcess::Convert(CString str,int sourceCodepage, int targetCodepage){ int len = str.GetLength(); int unicodeLen = MultiByteToWideChar(sourceCodepage,0,str,-1,NULL,0...

JavaEye_Blog 1776
上一篇: c++中字符数组或者字符串中的内容在VS debug环境中不能完全显示
下一篇: ASP.NET Image Manipulation Examples: Adding, Zooming, Enlarging
sinsel
博客等级 码龄20年 3粉丝 23原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址