Udostępnij za pośrednictwem


Charset.Encode Method

Definition

Overloads

Encode(String)

Convenience method that encodes a string into bytes in this charset.

Encode(CharBuffer)

Convenience method that encodes Unicode characters into bytes in this charset.

Encode(String)

Convenience method that encodes a string into bytes in this charset.

[Android.Runtime.Register("encode", "(Ljava/lang/String;)Ljava/nio/ByteBuffer;", "")]
public Java.Nio.ByteBuffer? Encode (string? str);
[<Android.Runtime.Register("encode", "(Ljava/lang/String;)Ljava/nio/ByteBuffer;", "")>]
member this.Encode : string -> Java.Nio.ByteBuffer

Parameters

str
String

The string to be encoded

Returns

A byte buffer containing the encoded characters

Attributes

Remarks

Convenience method that encodes a string into bytes in this charset.

An invocation of this method upon a charset cs returns the same result as the expression

cs.encode(CharBuffer.wrap(s));

Java documentation for java.nio.charset.Charset.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(CharBuffer)

Convenience method that encodes Unicode characters into bytes in this charset.

[Android.Runtime.Register("encode", "(Ljava/nio/CharBuffer;)Ljava/nio/ByteBuffer;", "")]
public Java.Nio.ByteBuffer? Encode (Java.Nio.CharBuffer? cb);
[<Android.Runtime.Register("encode", "(Ljava/nio/CharBuffer;)Ljava/nio/ByteBuffer;", "")>]
member this.Encode : Java.Nio.CharBuffer -> Java.Nio.ByteBuffer

Parameters

cb
CharBuffer

The char buffer to be encoded

Returns

A byte buffer containing the encoded characters

Attributes

Remarks

Convenience method that encodes Unicode characters into bytes in this charset.

An invocation of this method upon a charset cs returns the same result as the expression

cs.newEncoder()
                  .onMalformedInput(CodingErrorAction.REPLACE)
                  .onUnmappableCharacter(CodingErrorAction.REPLACE)
                  .encode(bb); 

except that it is potentially more efficient because it can cache encoders between successive invocations.

This method always replaces malformed-input and unmappable-character sequences with this charset's default replacement string. In order to detect such sequences, use the CharsetEncoder#encode(java.nio.CharBuffer) method directly.

Java documentation for java.nio.charset.Charset.encode(java.nio.CharBuffer).

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