Bidi.SetContext(String, String) Method
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.
Set the context before a call to setPara().
[Android.Runtime.Register("setContext", "(Ljava/lang/String;Ljava/lang/String;)V", "GetSetContext_Ljava_lang_String_Ljava_lang_String_Handler", ApiSince=29)]
public virtual void SetContext (string? prologue, string? epilogue);
[<Android.Runtime.Register("setContext", "(Ljava/lang/String;Ljava/lang/String;)V", "GetSetContext_Ljava_lang_String_Ljava_lang_String_Handler", ApiSince=29)>]
abstract member SetContext : string * string -> unit
override this.SetContext : string * string -> unit
Parameters
- prologue
- String
is the text which precedes the text that
will be specified in a coming call to setPara().
If there is no prologue to consider,
this parameter can be null
.
- epilogue
- String
is the text which follows the text that
will be specified in a coming call to setPara().
If there is no epilogue to consider,
this parameter can be null
.
- Attributes
Remarks
Set the context before a call to setPara().
setPara() computes the left-right directionality for a given piece of text which is supplied as one of its arguments. Sometimes this piece of text (the "main text") should be considered in context, because text appearing before ("prologue") and/or after ("epilogue") the main text may affect the result of this computation.
This function specifies the prologue and/or the epilogue for the next call to setPara(). If successive calls to setPara() all need specification of a context, setContext() must be called before each call to setPara(). In other words, a context is not "remembered" after the following successful call to setPara().
If a call to setPara() specifies DEFAULT_LTR or DEFAULT_RTL as paraLevel and is preceded by a call to setContext() which specifies a prologue, the paragraph level will be computed taking in consideration the text in the prologue.
When setPara() is called without a previous call to setContext, the main text is handled as if preceded and followed by strong directional characters at the current paragraph level. Calling setContext() with specification of a prologue will change this behavior by handling the main text as if preceded by the last strong character appearing in the prologue, if any. Calling setContext() with specification of an epilogue will change the behavior of setPara() by handling the main text as if followed by the first strong character or digit appearing in the epilogue, if any.
Note 1: if setContext
is called repeatedly without calling setPara
, the earlier calls have no effect, only the last call will be remembered for the next call to setPara
.
Note 2: calling setContext(null, null)
cancels any previous setting of non-empty prologue or epilogue. The next call to setPara()
will process no prologue or epilogue.
Note 3: users must be aware that even after setting the context before a call to setPara() to perform e.g. a logical to visual transformation, the resulting string may not be identical to what it would have been if all the text, including prologue and epilogue, had been processed together.<br> Example (upper case letters represent RTL characters):<br> prologue = "abc DE
"<br> epilogue = none<br> main text = "FGH xyz
"<br> paraLevel = LTR<br> display without prologue = "HGF xyz
" ("HGF" is adjacent to "xyz")<br> display with prologue = "abc HGFED xyz
" ("HGF" is not adjacent to "xyz")<br>
Java documentation for android.icu.text.Bidi.setContext(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.