问题描述
我用c语言读出一个文件的内容,然后组成url字符串,接着用函数打开对应的url,但是服务器端得到的数据被截断了,肯定是含有特殊字符,那我在c语言如何调用Server.UrlEncoding,代码如下:c语言:HANDLEhFile;hFile=CreateFile(TEXT("image.jpg"),GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);TCHARch[6000];DWORDdwReads,dwCount;ReadFile(hFile,ch,6000,&dwReads,NULL);ch[dwReads]=0;//文件数据末尾TCHAR*pch=ch;for(dwCount=512;dwCount<=dwReads;dwCount+=512){TCHARchURL[512]=TEXT("http://localhost/example/upload.asp?value=");memcpy(chURL+42,pch,512);ShellExecute(NULL,TEXT("open"),chURL,NULL,NULL,SW_SHOWNORMAL);pch+=256;}TCHARchURL[512]=TEXT("http://localhost/example/upload.asp?value=");memcpy(chURL+42,pch,dwReads+512-dwCount);ShellExecute(NULL,TEXT("open"),chURL,NULL,NULL,SW_SHOWNORMAL);asp代码:Dimvaluevalue=Request.QueryString("value")Response.Write(value)
解决方案
解决方案二:
要进行编码http://dev.csdn.net/article/49/49256.shtm
解决方案三:
CODE/*ReplaceescapesequencesinanURL(orapartofanURL)*//*workslikestrcpy(),butwithoutreturnargument*//*unescape_url_stringcomesfromASFRecorder*/voidurl_unescape_string(char*outbuf,constchar*inbuf){unsignedcharc;do{c=*inbuf++;if(c=='%'){unsignedcharc1=*inbuf++;unsignedcharc2=*inbuf++;if(((c1>='0'&&c1<='9')||(c1>='A'&&c1<='F'))&&((c2>='0'&&c2<='9')||(c2>='A'&&c2<='F'))){if(c1>='0'&&c1<='9')c1-='0';elsec1-='A'-10;if(c2>='0'&&c2<='9')c2-='0';elsec2-='A'-10;c=(c1<<4)+c2;}}*outbuf++=c;}while(c!='')输出c
解决方案四:
平时遇到这样的东西都是因为传了汉字而页的encoding="utf-8",改成gb2312这个就满足了楼主这个是传了特殊编码了,学习下
解决方案五:
web.Config文件加上<globalizationrequestEncoding="GB2312"responseEncoding="GB2312"uiCulture="zh-CN"culture="zh-CN"fileEncoding="GB2312"/>