老兄,这里不是UNICODE 是用三位表示一个中文或者特殊字符
看“我”这个字它的编码是%ce%d2
ASCII 很简单,汉字就烦了,不过你可以自己做一个库
想做吗?

解决方案 »

  1.   

        听了各位的高见,可惜还不是很明白。
    例如我在IE地址栏填:http://mysite.com/ab%c1%13cd%0a%4fef.asp,然后提交。
    那么IIS按照怎样的方法对URL中的%c1%13和%0a%4f解码为对应的ASCII码字符呢?
      

  2.   

    To Jady:
    WideCharToMutiByte不是这样用的吧?
    我需要的是把URL中的%xx%xx这样的编码转为单个ASCII字符。
      

  3.   

    等于就可以了
    char c = xx;
      

  4.   

    不是已经告诉你们了码
    在MSDN中察看InternetCrackUrl的帮助。
      

  5.   

    请问mathe()
    在UNIX下有没有对应InternetCrackUrl()的函数?因为我的函数要在非WINDOWS平台上运行的。
    帖子加分了,现在是100分。求各位指教。
      

  6.   

    各位帮忙啊,快要到Deadline了!!
      

  7.   

    UNICODE到ASCII的转换根本没有规律可循。它是由code page决定的。例如Big5与GBK中可能都有某个相同的汉字,那么它们的UNICODE编码将是相同的,但ASCII编码确是不同的——这种转换规则是根据你当前使用简体中文还是繁体中文的代码页决定的。如果你可以保证你的程序将只工作在简体中文代码页环境下,你可以试着将整个936代码页作为你的数据——那是很可怕的,数万个代码的对应关系。
    Windows下提供了WideCharToMultiByte函数,根据你指定的代码页完成UNICODE到ASCII的转换(当然,前提是系统必须安装了相应的代码页文件),不知道Unix下有没有类似的函数。
    最后就是字符串分析的问题,挑出“%”字符,并把其后两个字节换算为16进制值,这个应该比较简单。
    无论如何,如果你能在Unix下找到类似InternetCrackUrl之类的函数,那才是最好不过。
      

  8.   

    %CE%D2表示ASCII码为CED2的扩展字符(>127),当然CED2就是汉字"我",另外对于空格好象是%20,%25表示真正的'%',可能还有其它一些非打印字符也是用%+ASCII码的方式表示的。
      

  9.   

    其实这个编码也不麻烦,自己写一个code来分析也很简单呀。
      

  10.   


    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.