compat/src/main/java/androidx/core/text/BidiFormatter.java
private byte skipEntityBackward() {
            int initialCharIndex = charIndex;
            while (charIndex > 0) {
                lastChar = text.charAt(--charIndex);
                if (lastChar == '&') {
                    return Character.DIRECTIONALITY_WHITESPACE;
                }
                if (lastChar == ';') {
                    break;
                }
            }
            charIndex = initialCharIndex;
            lastChar = ';';
            return Character.DIRECTIONALITY_OTHER_NEUTRALS;
        }
/**
         * Advances charIndex backward through an HTML character entity tag (after the closing ;
         * has already been read) and returns Character.DIRECTIONALITY_WHITESPACE. It would be best
         * to figure out the actual character and return its dirtype, but this is good enough.
         * If there is no matching &amp;, does not change charIndex and returns
         * Character.DIRECTIONALITY_OTHER_NEUTRALS (for the ';' that did not start an entity after
         * all). Nevertheless, the running time for calling skipEntityBackward() in a loop remains
         * linear in the size of the text, even for a text like ";;;;;;;", because skipTagBackward()
         * also stops looking for a matching &amp; when it encounters another ;.
         */
Advances charIndex backward through an HTML character entity tag (after the closing ;
has already been read) and returns Character.DIRECTIONALITY_WHITESPACE. It would be best
to figure out the actual character and return its dirtype, but this is good enough.
If there is no matching &, does not change charIndex and returns
Character.DIRECTIONALITY_OTHER_NEUTRALS (for the ';' that did not start an entity after
all). Nevertheless, the running time for calling skipEntityBackward() in a loop remains
linear in the size of the text, even for a text like ";;;;;;;", because skipTagBackward()
also stops looking for a matching & when it encounters another ;.
Advances charIndex backward through an HTML character entity tag ( after the closing ; has already been read ) and returns Character . DIRECTIONALITY_WHITESPACE . It would be best to figure out the actual character and return its dirtype but this is good enough . If there is no matching & does not change charIndex and returns Character . DIRECTIONALITY_OTHER_NEUTRALS ( for the ' ; ' that did not start an entity after all ) . Nevertheless the running time for calling skipEntityBackward () in a loop remains linear in the size of the text even for a text like " ;;;;;;; " because skipTagBackward () also stops looking for a matching & when it encounters another ; .
private byte skipEntityBackward() {
            int initialCharIndex = charIndex;
            while (charIndex > 0) {
                lastChar = text.charAt(--charIndex);
                if (lastChar == '&') {
                    return Character.DIRECTIONALITY_WHITESPACE;
                }
                if (lastChar == ';') {
                    break;
                }
            }
            charIndex = initialCharIndex;
            lastChar = ';';
            return Character.DIRECTIONALITY_OTHER_NEUTRALS;
        }
private byte skipEntityBackward ( ) { int initialCharIndex = charIndex ; while ( charIndex > 0 ) { lastChar = text . charAt ( -- charIndex ) ; if ( lastChar == '&' ) { return Character . DIRECTIONALITY_WHITESPACE ; } if ( lastChar == ';' ) { break ; } } charIndex = initialCharIndex ; lastChar = ';' ; return Character . DIRECTIONALITY_OTHER_NEUTRALS ; }
Advances charIndex backward through an HTML character entity tag (after the closing ;
 has already been read) and returns Character.DIRECTIONALITY_WHITESPACE.
Advances charIndex backward through an HTML character entity tag ( after the closing ; has already been read ) and returns Character . DIRECTIONALITY_WHITESPACE .