CharsetDecoder Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
An engine that can transform a sequence of bytes in a specific charset into a sequence of sixteen-bit Unicode characters.
[Android.Runtime.Register("java/nio/charset/CharsetDecoder", DoNotGenerateAcw=true)]
public abstract class CharsetDecoder : Java.Lang.Object
[<Android.Runtime.Register("java/nio/charset/CharsetDecoder", DoNotGenerateAcw=true)>]
type CharsetDecoder = class
inherit Object
- Inheritance
- Attributes
Remarks
An engine that can transform a sequence of bytes in a specific charset into a sequence of sixteen-bit Unicode characters.
"steps">
The input byte sequence is provided in a byte buffer or a series of such buffers. The output character sequence is written to a character buffer or a series of such buffers. A decoder should always be used by making the following sequence of method invocations, hereinafter referred to as a decoding operation:
<ol>
<li>
Reset the decoder via the #reset reset
method, unless it has not been used before;
</li>
<li>
Invoke the #decode decode
method zero or more times, as long as additional input may be available, passing false
for the endOfInput
argument and filling the input buffer and flushing the output buffer between invocations;
</li>
<li>
Invoke the #decode decode
method one final time, passing true
for the endOfInput
argument; and then
</li>
<li>
Invoke the #flush flush
method so that the decoder can flush any internal state to the output buffer.
</li>
</ol>
Each invocation of the #decode decode
method will decode as many bytes as possible from the input buffer, writing the resulting characters to the output buffer. The #decode decode
method returns when more input is required, when there is not enough room in the output buffer, or when a decoding error has occurred. In each case a CoderResult
object is returned to describe the reason for termination. An invoker can examine this object and fill the input buffer, flush the output buffer, or attempt to recover from a decoding error, as appropriate, and try again.
"ce">
There are two general types of decoding errors. If the input byte sequence is not legal for this charset then the input is considered malformed. If the input byte sequence is legal but cannot be mapped to a valid Unicode character then an unmappable character has been encountered.
"cae">
How a decoding error is handled depends upon the action requested for that type of error, which is described by an instance of the CodingErrorAction
class. The possible error actions are to CodingErrorAction#IGNORE ignore the erroneous input, CodingErrorAction#REPORT report the error to the invoker via the returned CoderResult
object, or CodingErrorAction#REPLACE replace the erroneous input with the current value of the replacement string. The replacement
has the initial value "\uFFFD"
;
its value may be changed via the #replaceWith(java.lang.String) replaceWith
method.
The default action for malformed-input and unmappable-character errors is to CodingErrorAction#REPORT report them. The malformed-input error action may be changed via the #onMalformedInput(CodingErrorAction) onMalformedInput
method; the unmappable-character action may be changed via the #onUnmappableCharacter(CodingErrorAction) onUnmappableCharacter
method.
This class is designed to handle many of the details of the decoding process, including the implementation of error actions. A decoder for a specific charset, which is a concrete subclass of this class, need only implement the abstract #decodeLoop decodeLoop
method, which encapsulates the basic decoding loop. A subclass that maintains internal state should, additionally, override the #implFlush implFlush
and #implReset implReset
methods.
Instances of this class are not safe for use by multiple concurrent threads.
Added in 1.4.
Java documentation for java.nio.charset.CharsetDecoder
.
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.
Constructors
CharsetDecoder(Charset, Single, Single) |
Initializes a new decoder. |
CharsetDecoder(IntPtr, JniHandleOwnership) |
A constructor used when creating managed representations of JNI objects; called by the runtime. |
Properties
Class |
Returns the runtime class of this |
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
IsAutoDetecting |
Tells whether or not this decoder implements an auto-detecting charset. |
IsCharsetDetected |
Tells whether or not this decoder has yet detected a charset (optional operation). |
JniIdentityHashCode | (Inherited from Object) |
JniPeerMembers | |
PeerReference | (Inherited from Object) |
ThresholdClass |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
ThresholdType |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
Methods
AverageCharsPerByte() |
Returns the average number of characters that will be produced for each byte of input. |
Charset() |
Returns the charset that created this decoder. |
Clone() |
Creates and returns a copy of this object. (Inherited from Object) |
Decode(ByteBuffer, CharBuffer, Boolean) |
Decodes as many bytes as possible from the given input buffer, writing the results to the given output buffer. |
Decode(ByteBuffer) |
Convenience method that decodes the remaining content of a single input byte buffer into a newly-allocated character buffer. |
DecodeLoop(ByteBuffer, CharBuffer) |
Decodes one or more bytes into one or more characters. |
DetectedCharset() |
Retrieves the charset that was detected by this decoder (optional operation). |
Dispose() | (Inherited from Object) |
Dispose(Boolean) | (Inherited from Object) |
Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
Flush(CharBuffer) |
Flushes this decoder. |
GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
ImplFlush(CharBuffer) |
Flushes this decoder. |
ImplOnMalformedInput(CodingErrorAction) |
Reports a change to this decoder's malformed-input action. |
ImplOnUnmappableCharacter(CodingErrorAction) |
Reports a change to this decoder's unmappable-character action. |
ImplReplaceWith(String) |
Reports a change to this decoder's replacement value. |
ImplReset() |
Resets this decoder, clearing any charset-specific internal state. |
JavaFinalize() |
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. (Inherited from Object) |
MalformedInputAction() |
Returns this decoder's current action for malformed-input errors. |
MaxCharsPerByte() |
Returns the maximum number of characters that will be produced for each byte of input. |
Notify() |
Wakes up a single thread that is waiting on this object's monitor. (Inherited from Object) |
NotifyAll() |
Wakes up all threads that are waiting on this object's monitor. (Inherited from Object) |
OnMalformedInput(CodingErrorAction) |
Changes this decoder's action for malformed-input errors. |
OnUnmappableCharacter(CodingErrorAction) |
Changes this decoder's action for unmappable-character errors. |
Replacement() |
Returns this decoder's replacement value. |
ReplaceWith(String) |
Changes this decoder's replacement value. |
Reset() |
Resets this decoder, clearing any internal state. |
SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
ToArray<T>() | (Inherited from Object) |
ToString() |
Returns a string representation of the object. (Inherited from Object) |
UnmappableCharacterAction() |
Returns this decoder's current action for unmappable-character errors. |
UnregisterFromRuntime() | (Inherited from Object) |
Wait() |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>. (Inherited from Object) |
Wait(Int64, Int32) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Wait(Int64) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Explicit Interface Implementations
IJavaPeerable.Disposed() | (Inherited from Object) |
IJavaPeerable.DisposeUnlessReferenced() | (Inherited from Object) |
IJavaPeerable.Finalized() | (Inherited from Object) |
IJavaPeerable.JniManagedPeerState | (Inherited from Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from Object) |
Extension Methods
JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
JavaCast<TResult>(IJavaObject) | |
GetJniTypeName(IJavaPeerable) |