标准的 URL 编码功能? [英] Standard URL encode function?

查看:17
本文介绍了标准的 URL 编码功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有与此 .net 方法等效的 Delphi:

Is there a Delphi equivalent of this .net's method:

Url.UrlEncode()

注意
我已经好几年没有与 Delphi 合作了.当我通读答案时,我注意到当前标记的答案有几个评论和替代方案.我还没有机会测试它们,所以我的回答是基于最受好评的.
为了您自己,请检查以后的答案,并在决定最佳答案后投票,以便每个人都可以从您的经验中受益.

Note
I haven't worked with Delphi for several years now. As I read through the answers I notice that there are several remarks and alternatives to the currently marked answer. I haven't had the opportunity to test them so I'm basing my answer on the most upvoted.
For your own sake, do check later answers and after deciding upvote the best answer so everybody can benefit from your experience.

推荐答案

看 indy IdURI 单元,它在 TIdURI 类中有两个静态方法,用于对 URL 进行编码/解码.

Look at indy IdURI unit, it has two static methods in the TIdURI class for Encode/Decode the URL.

uses
  IdURI;

..
begin
  S := TIdURI.URLEncode(str);
//
  S := TIdURI.URLDecode(str);
end;

这篇关于标准的 URL 编码功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆