encoder class : UrlEncode(string,string) method

Description

Encodes a string using URL encoding and specified character encoding.

Syntax

encoderInstance.UrlEncode(string anyString, string encodingName)

Arguments

ClassNameDescription
stringanyStringA string.
stringencodingNameA encoding name.

Return value

ClassDescription
stringA string encoded by URL encoding.

Sample code

1:

encoder e = new encoder();

2:

string any = "日本語";

3:

string encoded = e.UrlEncode(any, "shift_jis"); // The result is "%93%FA%96%7B%8C%EA".

Notes

It's a wrapper of the System.Web.HttpUtility.UrlEncode(String,Encoding) method.

Links for reference

Copyright © Cooker All rights reserved.