Aracılığıyla paylaş


BidiFormatter Class

Definition

Utility class for formatting text for display in a potentially opposite-directionality context without garbling.

[Android.Runtime.Register("android/text/BidiFormatter", DoNotGenerateAcw=true)]
public sealed class BidiFormatter : Java.Lang.Object
[<Android.Runtime.Register("android/text/BidiFormatter", DoNotGenerateAcw=true)>]
type BidiFormatter = class
    inherit Object
Inheritance
BidiFormatter
Attributes

Remarks

Utility class for formatting text for display in a potentially opposite-directionality context without garbling. The directionality of the context is set at formatter creation and the directionality of the text can be either estimated or passed in when known.

To support versions lower than android.os.Build.VERSION_CODES#JELLY_BEAN_MR2, you can use the support library's androidx.core.text.BidiFormatter class.

These APIs provides the following functionality:

1. Bidi Wrapping When text in one language is mixed into a document in another, opposite-directionality language, e.g. when an English business name is embedded in some Hebrew text, both the inserted string and the text surrounding it may be displayed incorrectly unless the inserted string is explicitly separated from the surrounding text in a "wrapper" that:

- Declares its directionality so that the string is displayed correctly. This can be done in Unicode bidi formatting codes by #unicodeWrap and similar methods.

- Isolates the string's directionality, so it does not unduly affect the surrounding content. Currently, this can only be done using invisible Unicode characters of the same direction as the context (LRM or RLM) in addition to the directionality declaration above, thus "resetting" the directionality to that of the context. The "reset" may need to be done at both ends of the string. Without "reset" after the string, the string will "stick" to a number or logically separate opposite-direction text that happens to follow it in-line (even if separated by neutral content like spaces and punctuation). Without "reset" before the string, the same can happen there, but only with more opposite-direction text, not a number. One approach is to "reset" the direction only after each string, on the theory that if the preceding opposite- direction text is itself bidi-wrapped, the "reset" after it will prevent the sticking. (Doing the "reset" only before each string definitely does not work because we do not want to require bidi-wrapping numbers, and a bidi-wrapped opposite-direction string could be followed by a number.) Still, the safest policy is to do the "reset" on both ends of each string, since RTL message translations often contain untranslated Latin-script brand names and technical terms, and one of these can be followed by a bidi-wrapped inserted value. On the other hand, when one has such a message, it is best to do the "reset" manually in the message translation itself, since the message's opposite-direction text could be followed by an inserted number, which we would not bidi-wrap anyway. Thus, "reset" only after the string is the current default. In an alternative to "reset", recent additions to the HTML, CSS, and Unicode standards allow the isolation to be part of the directionality declaration. This form of isolation is better than "reset" because it takes less space, does not require knowing the context directionality, has a gentler effect than "reset", and protects both ends of the string. However, we do not yet allow using it because required platforms do not yet support it.

Providing these wrapping services is the basic purpose of the bidi formatter.

2. Directionality estimation How does one know whether a string about to be inserted into surrounding text has the same directionality? Well, in many cases, one knows that this must be the case when writing the code doing the insertion, e.g. when a localized message is inserted into a localized page. In such cases there is no need to involve the bidi formatter at all. In some other cases, it need not be the same as the context, but is either constant (e.g. urls are always LTR) or otherwise known. In the remaining cases, e.g. when the string is user-entered or comes from a database, the language of the string (and thus its directionality) is not known a priori, and must be estimated at run-time. The bidi formatter can do this automatically using the default first-strong estimation algorithm. It can also be configured to use a custom directionality estimation object.

Java documentation for android.text.BidiFormatter.

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.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
Instance

Factory for creating an instance of BidiFormatter for the default locale directionality.

IsRtlContext
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
StereoReset
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetInstance(Boolean)

Factory for creating an instance of BidiFormatter given the context directionality.

GetInstance(Locale)

Factory for creating an instance of BidiFormatter given the context locale.

IsRtl(ICharSequence)

Operates like #isRtl(String), but takes a CharSequence instead of a string

IsRtl(String)

Estimates the directionality of a string using the default text direction heuristic.

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)
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)
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)
UnicodeWrap(String, Boolean)

Operates like #unicodeWrap(CharSequence, TextDirectionHeuristic, boolean), but uses the formatter's default direction estimation algorithm.

UnicodeWrap(String, ITextDirectionHeuristic, Boolean)

Operates like #unicodeWrap(String, TextDirectionHeuristic, boolean), but takes a CharSequence instead of a string

UnicodeWrap(String, ITextDirectionHeuristic)

Operates like #unicodeWrap(CharSequence, TextDirectionHeuristic, boolean), but assumes isolate is true.

UnicodeWrap(String)

Operates like #unicodeWrap(CharSequence, TextDirectionHeuristic, boolean), but uses the formatter's default direction estimation algorithm and assumes isolate is true.

UnicodeWrapFormatted(ICharSequence, Boolean)

Operates like #unicodeWrap(CharSequence, TextDirectionHeuristic, boolean), but uses the formatter's default direction estimation algorithm.

UnicodeWrapFormatted(ICharSequence, ITextDirectionHeuristic, Boolean)

Operates like #unicodeWrap(String, TextDirectionHeuristic, boolean), but takes a CharSequence instead of a string

UnicodeWrapFormatted(ICharSequence, ITextDirectionHeuristic)

Operates like #unicodeWrap(CharSequence, TextDirectionHeuristic, boolean), but assumes isolate is true.

UnicodeWrapFormatted(ICharSequence)

Operates like #unicodeWrap(CharSequence, TextDirectionHeuristic, boolean), but uses the formatter's default direction estimation algorithm and assumes isolate is true.

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)

Applies to