URLEncoder.Encode Method

Definition

Overloads

Encode(String)
Obsolete.

Translates a string into x-www-form-urlencoded format.

Encode(String, Charset)

Translates a string into application/x-www-form-urlencoded format using a specific java.

Encode(String, String)

Translates a string into application/x-www-form-urlencoded format using a specific encoding scheme.

Encode(String)

Caution

deprecated

Translates a string into x-www-form-urlencoded format.

[Android.Runtime.Register("encode", "(Ljava/lang/String;)Ljava/lang/String;", "")]
[System.Obsolete("deprecated")]
public static string? Encode (string? s);
[<Android.Runtime.Register("encode", "(Ljava/lang/String;)Ljava/lang/String;", "")>]
[<System.Obsolete("deprecated")>]
static member Encode : string -> string

Parameters

s
String

String to be translated.

Returns

the translated String.

Attributes

Remarks

Translates a string into x-www-form-urlencoded format. This method uses the platform's default encoding as the encoding scheme to obtain the bytes for unsafe characters.

This member is deprecated. The resulting string may vary depending on the platform's default encoding. Instead, use the encode(String,String) method to specify the encoding.

Java documentation for java.net.URLEncoder.encode(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Encode(String, Charset)

Translates a string into application/x-www-form-urlencoded format using a specific java.

[Android.Runtime.Register("encode", "(Ljava/lang/String;Ljava/nio/charset/Charset;)Ljava/lang/String;", "", ApiSince=33)]
public static string? Encode (string? s, Java.Nio.Charset.Charset? charset);
[<Android.Runtime.Register("encode", "(Ljava/lang/String;Ljava/nio/charset/Charset;)Ljava/lang/String;", "", ApiSince=33)>]
static member Encode : string * Java.Nio.Charset.Charset -> string

Parameters

s
String

String to be translated.

charset
Charset

the given charset

Returns

the translated String.

Attributes

Remarks

Translates a string into application/x-www-form-urlencoded format using a specific java.nio.charset.Charset Charset. This method uses the supplied charset to obtain the bytes for unsafe characters.

<em><strong>Note:</strong> The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilities.</em>

Added in 10.

Java documentation for java.net.URLEncoder.encode(java.lang.String, java.nio.charset.Charset).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

Encode(String, String)

Translates a string into application/x-www-form-urlencoded format using a specific encoding scheme.

[Android.Runtime.Register("encode", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", "")]
public static string? Encode (string? s, string? enc);
[<Android.Runtime.Register("encode", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", "")>]
static member Encode : string * string -> string

Parameters

s
String

String to be translated.

enc
String

The name of a supported character encoding.

Returns

the translated String.

Attributes

Exceptions

Remarks

Translates a string into application/x-www-form-urlencoded format using a specific encoding scheme.

This method behaves the same as String encode(String s, Charset charset) except that it will java.nio.charset.Charset#forName look up the charset using the given encoding name.

Added in 1.4.

Java documentation for java.net.URLEncoder.encode(java.lang.String, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to