자료실

부자는 돈을 써서 시간을 아끼지만 가난한 사람은 시간을 써서 돈을 아낀다

vb.net

IT HUB를 찾아주셔서 감사합니다.

WinHttp [vb.net] UrlEncode

페이지 정보

profile_image
작성자 하나를하더라도최선을
댓글 0건 조회 7,081회 작성일 20-04-01 12:08

본문

Couldn't find any good examples comparing them so:

string testString = "http://test# space 123/text?var=val&another=two";

Console.WriteLine("UrlEncode: " + System.Web.HttpUtility.UrlEncode(testString));

Console.WriteLine("EscapeUriString: " + Uri.EscapeUriString(testString));

Console.WriteLine("EscapeDataString: " + Uri.EscapeDataString(testString));

Console.WriteLine("EscapeDataReplace: " + Uri.EscapeDataString(testString).Replace("%20", "+"));

Console.WriteLine("HtmlEncode: " + System.Web.HttpUtility.HtmlEncode(testString));

Console.WriteLine("UrlPathEncode: " + System.Web.HttpUtility.UrlPathEncode(testString));


//.Net 4.0+

Console.WriteLine("WebUtility.HtmlEncode: " + WebUtility.HtmlEncode(testString));


//.Net 4.5+

Console.WriteLine("WebUtility.UrlEncode: " + WebUtility.UrlEncode(testString));


Outputs:

UrlEncode: http%3a%2f%2ftest%23+space+123%2ftext%3fvar%3dval%26another%3dtwo

EscapeUriString: http://test#%20space%20123/text?var=val&another=two

EscapeDataString: http%3A%2F%2Ftest%23%20space%20123%2Ftext%3Fvar%3Dval%26another%3Dtwo

EscapeDataReplace: http%3A%2F%2Ftest%23+space+123%2Ftext%3Fvar%3Dval%26another%3Dtwo

HtmlEncode: http://test# space 123/text?var=val&another=two

UrlPathEncode: http://test#%20space%20123/text?var=val&another=two


//.Net 4.0+

WebUtility.HtmlEncode: http://test# space 123/text?var=val&another=two


//.Net 4.5+

WebUtility.UrlEncode: http%3A%2F%2Ftest%23+space+123%2Ftext%3Fvar%3Dval%26another%3Dtwo



댓글목록

등록된 댓글이 없습니다.