老兄,这里不是UNICODE 是用三位表示一个中文或者特殊字符
看“我”这个字它的编码是%ce%d2
ASCII 很简单,汉字就烦了,不过你可以自己做一个库
想做吗?
看“我”这个字它的编码是%ce%d2
ASCII 很简单,汉字就烦了,不过你可以自己做一个库
想做吗?
解决方案 »
- 关于winpcap?
- 帮忙回3个帖子~~好结帖,都100分的,没人回..谁帮回一帖?分全给了~~
- 进程虚拟地址的用户区大小?
- 关于MapObject的一个简单的问题,请帮帮我
- 关于CMetaFileDC类的小问题,高手帮支个着
- 如何让treectrl右边出现加号?谢谢
- 为了答谢‘kongyunzhongque(云雀) ‘的卓越洞察力请kongyunzhongque(云雀)进来接分
- 怎样用VC实现录音机的录音和存储功能 (用对话框做的简单录音机)
- 怎样将一段内存空间的数据强制存入一个CString 变量中
- 迷茫:30岁后,程序员做什么工作?
- 如何在程序里调用IE的功能下载网页?
- ISAPI中线程池的应用。
例如我在IE地址栏填:http://mysite.com/ab%c1%13cd%0a%4fef.asp,然后提交。
那么IIS按照怎样的方法对URL中的%c1%13和%0a%4f解码为对应的ASCII码字符呢?
WideCharToMutiByte不是这样用的吧?
我需要的是把URL中的%xx%xx这样的编码转为单个ASCII字符。
char c = xx;
在MSDN中察看InternetCrackUrl的帮助。
在UNIX下有没有对应InternetCrackUrl()的函数?因为我的函数要在非WINDOWS平台上运行的。
帖子加分了,现在是100分。求各位指教。
Windows下提供了WideCharToMultiByte函数,根据你指定的代码页完成UNICODE到ASCII的转换(当然,前提是系统必须安装了相应的代码页文件),不知道Unix下有没有类似的函数。
最后就是字符串分析的问题,挑出“%”字符,并把其后两个字节换算为16进制值,这个应该比较简单。
无论如何,如果你能在Unix下找到类似InternetCrackUrl之类的函数,那才是最好不过。
UrlUnescape
Converts escape sequences back into ordinary characters.HRESULT UrlUnescape(
LPTSTR pszURL,
LPTSTR pszUnescaped,
LPDWORD pcchUnescaped,
DWORD dwFlags
);Parameters
pszURL
[in/out] Pointer to a null-terminated string with the URL. If dwFlags is set to URL_UNESCAPE_INPLACE, the converted string is returned through this parameter.
pszUnescaped
[out] Pointer to a buffer that will receive a null-terminated string containing the unescaped version of pszURL. If URL_UNESCAPE_INPLACE is set in dwFlags, this parameter is ignored.
pcchUnescaped
[in/out] Number of characters in the buffer pointed to by pcchUnescaped. On entry, the value pcchUnescaped points to is set to the size of the buffer. If the function returns a success code, the value that pcchUnescaped points to is set to the number of characters written to that buffer, not counting the terminating NULL character. If an E_POINTER error code is returned, the buffer was too small, and the value pcchUnescaped points to is set to the required number of characters that the buffer must be able to contain. If any other errors are returned, the value that pcchUnescaped points to is undefined.
dwFlags
[in] Flags that control which characters are unescaped. It can be a combination of the following flags. Flag Description
URL_DONT_UNESCAPE_EXTRA_INFO Don't convert the # or ? character, or any characters following them in the string.
URL_UNESCAPE_INPLACE Use pszURL to return the converted string instead of pszUnescaped. Return Values
Returns an OLE success code if successful. If the URL_UNESCAPE_INPLACE flag is not set, the value pointed to by pcchUnescaped will be set to the number of characters in the output buffer pointed to by pszUnescaped. Returns E_POINTER if the URL_UNESCAPE_INPLACE flag is not set and the output buffer is too small. The pcchUnescaped parameter will be set to the required buffer size. Otherwise, returns an OLE error value.Res
An escape sequence has the form "%xy".Input strings cannot be longer than INTERNET_MAX_URL_LENGTH.Requirements
Version 5.00 and later of Shlwapi.dll Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with Internet Explorer 5.0 or later).
Windows 95/98/Me: Requires Windows 98 (or Windows 95 with Internet Explorer 5.0 or later).
Header: Declared in Shlwapi.h.
Import Library: Shlwapi.lib.