UrlEscape函数的使用。

dreamchild 2003-10-31 07:45:39
UrlEscape的功能好像是:
把“使用说明”转换成:
“%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E”

但是我不懂得这个函数要如何使用,MSDN内说要用到
Header shlwapi.h
Import library shlwapi.lib
我在程序内加入#include "shlwapi.h"但是好像程序还是无法识别这个函数。
各位帮忙
...全文
690 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dreamchild 2003-11-01
  • 打赏
  • 举报
回复
也简单的说是UTF编码,要如何做?
dreamchild 2003-10-31
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2292/2292448.xml?temp=.5162622
这一贴是说反过来的。

不然像我所说的那样子,除了这个函数要如何转换呢?
我觉得98内应该有的,URL转换很普通的,好多地方的把汉字转为像%XX%XX的地方很多。
我贴2003的出来,您看一下:
UrlEscape Function

--------------------------------------------------------------------------------

Converts characters in a URL that might be altered during transport across the Internet ("unsafe" characters) into their corresponding escape sequences.

Syntax

HRESULT UrlEscape( LPCTSTR pszURL,
LPTSTR pszEscaped,
LPDWORD pcchEscaped,
DWORD dwFlags
);
Parameters

pszURL
[in] Null-terminated string of maximum length INTERNET_MAX_URL_LENGTH that contains a full or partial URL, as appropriate for the value in dwFlags.
pszEscaped
[out] Buffer that receives the converted string, with the unsafe characters converted to their escape sequences.
pcchEscaped
[in, out] Pointer to a DWORD value containing the number of characters in the pszEscaped buffer. Before calling UrlEscape, the caller must set the value referenced by pcchEscaped to the size of the buffer. On exit, that value is set to the number of characters written to the buffer, not including the terminating NULL character.
If an E_POINTER error code is returned, the buffer was too small to hold the result, and the value referenced by pcchEscaped is set to the required number of characters in the buffer. If any other errors are returned, the value referenced by pcchEscaped is undefined.

dwFlags
[in] Flags that indicate which portion of the URL is being provided in pszURL and which characters in that string should be converted to their escape sequences. The following flags are defined.
URL_DONT_ESCAPE_EXTRA_INFO
Used only in conjunction with URL_ESCAPE_SPACES_ONLY to prevent the conversion of characters in the query (the portion of the URL following the first # or ? character encountered in the string). This flag should not be used alone, nor combined with URL_ESCAPE_SEGMENT_ONLY.
URL_ESCAPE_SPACES_ONLY
Convert only space characters to their escape sequences, including those space characters in the query portion of the URL. Other unsafe characters are not converted to their escape sequences. This flag assumes that pszURL does not contain a full URL. It expects only the portions following the server specification.
Combine this flag with URL_DONT_ESCAPE_EXTRA_INFO to prevent the conversion of space characters in the query portion of the URL.

This flag cannot be combined with URL_ESCAPE_PERCENT or URL_ESCAPE_SEGMENT_ONLY.

URL_ESCAPE_PERCENT
Convert any % character found in the segment section of the URL (that section falling between the server specification and the first # or ? character). By default, the % character is not converted to its escape sequence. Other unsafe characters in the segment are also converted normally.
Combining this flag with URL_ESCAPE_SEGMENT_ONLY includes those % characters in the query portion of the URL. However, as the URL_ESCAPE_SEGMENT_ONLY flag causes the entire string to be considered the segment, any # or ? characters are also converted.

This flag cannot be combined with URL_ESCAPE_SPACES_ONLY.

URL_ESCAPE_SEGMENT_ONLY
Indicates that pszURL contains only that section of the URL following the server component but preceeding the query. All unsafe characters in the string are converted. If a full URL is provided when this flag is set, all unsafe characters in the entire string are converted, including # and ? characters.
Combine this flag with URL_ESCAPE_PERCENT to include that character in the conversion.

This flag cannot be combined with URL_ESCAPE_SPACES_ONLY or URL_DONT_ESCAPE_EXTRA_INFO.

Return Value

Returns S_OK if successful. If the pcchEscaped buffer was too small to contain the result, E_POINTER is returned, and the value pointed to by pcchEscaped is set to the required buffer size. Otherwise, a standard error value is returned.

Remarks

For the purposes of this document, a typical URL is divided into three sections: the server, the segment, and the query. For example, consider this URL.

http://microsoft.com/test.asp?url=/example/abc.asp?frame=true#fragment

The server portion is "http://microsoft.com/". The trailing forward slash is considered part of the server portion.
The segment portion is any part of the path found following the server portion, but before the first # or ? character, in this case simply "test.asp".

The query portion is the remainder of the path from the first # or ? character (inclusive) to the end. In the example, it is "?url=/example/abc.asp?frame=true#fragment".

Unsafe characters are those characters that might be altered during transport across the Internet. This function converts unsafe characters into their equivalent "%xy" escape sequences. The following table shows unsafe characters and their escape sequences.

Character Escape Sequence
^ %5E
& %26
` %60
{ %7B
} %7D
| %7C
] %5D
[ %5B
" %22
< %3C
> %3E
\ %5C

Use of the URL_ESCAPE_SEGMENT_ONLY flag also causes the conversion of the # (%23), ? (%3F), and / (%2F) characters.

By default, UrlEscape ignores any text following a # or ? character. The URL_ESCAPE_SEGMENT_ONLY flag overrides this behavior by regarding the entire string as the segment. The URL_ESCAPE_SPACES_ONLY flag overrides this behavior, but only for space characters.

Security Alert This function should be called from client applications only. For more information, see Security Considerations: Microsoft Windows Shell and Michael Howard and David LeBlanc, Writing Secure Code. Microsoft Press, Redmond, WA, 2002.
Example

The following examples show the effect of the various flags on a URL. The example URL is not valid but is exaggerated for demonstration purposes.

Show Example

// The full original URL
http://microsoft.com/test/t%e<s t.asp?url=/{ex% ample</abc.asp?frame=true#fr%agment

// URL_ESCAPE_SPACES_ONLY
// Only space characters are escaped. Other unsafe characters are ignored.
// Note: This flag expects the server portion of the URL to be omitted.
Original = test/t%e<s t.asp?url=/{ex% ample</abc.asp?frame=true#fr%agment
Result = test/t%e<s%20t.asp?url=/{ex%%20ample</abc.asp?frame=true#fr%agment

// URL_ESCAPE_SPACES_ONLY | URL_DONT_ESCAPE_EXTRA_INFO
// Spaces in the segment are converted into their escape sequences, but
// spaces in the query are not.
Original = test/t%e<s t.asp?url=/{ex% ample</abc.asp?frame=true#fr%agment
Result = test/t%e<s%20t.asp?url=/{ex% ample</abc.asp?frame=true#fr%agment

// URL_ESCAPE_PERCENT
// Here we supply only the segment and query, omitting the server component,
// although that is not required. Only the segment is considered.
// All unsafe characters plus the % character are converted in the segment.
Original = test/t%e<s t.asp?url=/{ex% ample</abc.asp?frame=true#fr%agment
Result = test/t%25e%3Cs%20t.asp?url=/{ex% ample</abc.asp?frame=true#fr%agment

// URL_ESCAPE_SEGMENT_ONLY
// Note: This flag expects only the segment, omitting the server and query
// components.
// The / character is escaped as well as the usual unsafe characters.
Original = test/t%e<s t.asp
Result = test%2Ft%e%3Cs%20t.asp
Function Information

Minimum DLL Version shlwapi.dll version 5.0 or later
Custom Implementation No
Header shlwapi.h
Import library shlwapi.lib
Minimum operating systems Windows 2000, Windows NT 4.0 with Internet Explorer 5, Windows 98, Windows 95 with Internet Explorer 5

See Also

Handling Uniform Resource Locators

--------------------------------------------------------------------------------

© 2003 Microsoft Corporation. All rights
akiko 2003-10-31
  • 打赏
  • 举报
回复
MSDN2003里有UrlEscape的说明吧,我手边的MSDN98就没有
dreamchild 2003-10-31
  • 打赏
  • 举报
回复
好像在那个lib内。
akiko 2003-10-31
  • 打赏
  • 举报
回复
我在shlwapi.h里找了一下,没有UrlEscape这个字符串,是不是要下载新的SDK

16,550

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧