本文整理汇总了Java中com.ibm.icu.lang.UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC属性的典型用法代码示例。如果您正苦于以下问题:Java UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC属性的具体用法?Java UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC怎么用?Java UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.ibm.icu.lang.UCharacter
的用法示例。
在下文中一共展示了UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requiresBidi
/**
* Return true if the specified text requires bidi analysis. If this returns
* false, the text will display left-to-right. Clients can then avoid
* constructing a Bidi object. Text in the Arabic Presentation Forms area of
* Unicode is presumed to already be shaped and ordered for display, and so
* will not cause this method to return true.
*
* @param text the text containing the characters to test
* @param start the start of the range of characters to test
* @param limit the limit of the range of characters to test
*
* @return true if the range of characters requires bidi analysis
*
* @stable ICU 3.8
*/
public static boolean requiresBidi(char[] text,
int start,
int limit)
{
final int RTLMask = (1 << UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT |
1 << UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC |
1 << UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING |
1 << UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE |
1 << UCharacter.DIRECTIONALITY_ARABIC_NUMBER);
for (int i = start; i < limit; ++i) {
if (((1 << UCharacter.getDirection(text[i])) & RTLMask) != 0) {
return true;
}
}
return false;
}
示例2: isRtl
/**
* @param ch
* @return
*/
private boolean isRtl( char ch )
{
byte direction = UCharacter.getDirectionality( ch );
return UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT == direction
|| UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC == direction;
}
示例3: getExitDir
/**
* Returns the directionality of the last character with strong directionality in the string, or
* Dir.NEUTRAL if none was encountered. For efficiency, actually scans backwards from the end of
* the string. Treats a non-BN character between an LRE/RLE/LRO/RLO and its matching PDF as a
* strong character, LTR after LRE/LRO, and RTL after RLE/RLO. The results are undefined for a
* string containing unbalanced LRE/RLE/LRO/RLO/PDF characters.
*/
Dir getExitDir() {
// The reason for this method name, as opposed to getLastStrongDir(), is that "last strong"
// sounds like the exact opposite of "first strong", which is a commonly used description of
// Unicode's estimation algorithm (getUnicodeDir() above), but the two must treat formatting
// characters quite differently. Thus, we are staying away from both "first" and "last" in
// these method names to avoid confusion.
charIndex = length;
int embeddingLevel = 0;
int lastNonEmptyEmbeddingLevel = 0;
while (charIndex > 0) {
switch (dirTypeBackward()) {
case UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT:
if (embeddingLevel == 0) {
return Dir.LTR;
}
if (lastNonEmptyEmbeddingLevel == 0) {
lastNonEmptyEmbeddingLevel = embeddingLevel;
}
break;
case UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:
case UCharacter.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:
if (lastNonEmptyEmbeddingLevel == embeddingLevel) {
return Dir.LTR;
}
--embeddingLevel;
break;
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT:
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
if (embeddingLevel == 0) {
return Dir.RTL;
}
if (lastNonEmptyEmbeddingLevel == 0) {
lastNonEmptyEmbeddingLevel = embeddingLevel;
}
break;
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:
case UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:
if (lastNonEmptyEmbeddingLevel == embeddingLevel) {
return Dir.RTL;
}
--embeddingLevel;
break;
case UCharacter.DIRECTIONALITY_POP_DIRECTIONAL_FORMAT:
++embeddingLevel;
break;
case UCharacter.BOUNDARY_NEUTRAL:
break;
default:
if (lastNonEmptyEmbeddingLevel == 0) {
lastNonEmptyEmbeddingLevel = embeddingLevel;
}
break;
}
}
return Dir.NEUTRAL;
}