通过querystring传送特殊字符串出现的问题,跪求答案
我用c语言读出一个文件的内容,然后组成url字符串,接着用函数打开对应的url,但是服务器端得到的数据被截断了,肯定是含有特殊字符,那我在c语言如何调用Server.UrlEncoding ,代码如下:c语言:
HANDLE hFile;
hFile = CreateFile(TEXT("image.jpg"), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
TCHAR ch[6000];
DWORD dwReads, dwCount;
ReadFile(hFile, ch, 6000, &dwReads, NULL);
ch[dwReads] = 0; //文件数据末尾
TCHAR *pch = ch;
for(dwCount = 512; dwCount <= dwReads; dwCount += 512)
{
TCHAR chURL[512] = TEXT("http://localhost/example/upload.asp?value=");
memcpy(chURL + 42, pch, 512);
ShellExecute(NULL, TEXT("open"), chURL, NULL, NULL, SW_SHOWNORMAL);
pch += 256;
}
TCHAR chURL[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代码:
Dim value
value = Request.QueryString("value")
Response.Write(value) --------------------编程问答-------------------- 要进行编码
http://dev.csdn.net/article/49/49256.shtm --------------------编程问答--------------------
CODE
/* Replace escape sequences in an URL (or a part of an URL) */
/* works like strcpy(), but without return argument */
/* unescape_url_string comes from ASFRecorder */
void
url_unescape_string(char *outbuf, const char *inbuf)
{
unsigned char c;
do {
c = *inbuf++;
if (c == '%') {
unsigned char c1 = *inbuf++;
unsigned char c2 = *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';
else c1-='A'-10;
if (c2>='0' && c2<='9') c2-='0';
else c2-='A'-10;
c = (c1<<4) + c2;
}
}
*outbuf++ = c;
} while (c != '')
输出c --------------------编程问答-------------------- 平时遇到这样的东西都是因为传了汉字而页的 encoding="utf-8" ,改成gb2312这个就满足了
楼主这个是传了特殊编码了,学习下 --------------------编程问答-------------------- web.Config文件加上 <globalization requestEncoding="GB2312" responseEncoding="GB2312" uiCulture="zh-CN" culture="zh-CN" fileEncoding="GB2312" />
补充:.NET技术 , ASP.NET