compat/src/main/java/androidx/core/text/BidiFormatter.java
private String markBefore(CharSequence str, TextDirectionHeuristicCompat heuristic) {
        final boolean isRtl = heuristic.isRtl(str, 0, str.length());
        // getEntryDir() is called only if needed (short-circuit).
        if (!mIsRtlContext && (isRtl || getEntryDir(str) == DIR_RTL)) {
            return LRM_STRING;
        }
        if (mIsRtlContext && (!isRtl || getEntryDir(str) == DIR_LTR)) {
            return RLM_STRING;
        }
        return EMPTY_STRING;
    }
/**
     * Returns a Unicode bidi mark matching the context directionality (LRM or RLM) if either the
     * overall or the entry directionality of a given CharSequence is opposite to the context
     * directionality. Putting this before the CharSequence (including its directionality
     * declaration wrapping) prevents it from "sticking" to other opposite-directionality text
     * appearing before it inline with only neutral content in between. Otherwise returns the
     * empty string. While the entry directionality is determined by scanning the beginning of the
     * CharSequence, the overall directionality is given explicitly by a heuristic to estimate the
     * {@code str}'s directionality.
     *
     * @param str CharSequence before which the mark may need to appear.
     * @param heuristic The text direction heuristic that will be used to estimate the {@code str}'s
     *                  directionality.
     * @return LRM for RTL text in LTR context; RLM for LTR text in RTL context;
     *     else, the empty string.
     */
Returns a Unicode bidi mark matching the context directionality (LRM or RLM) if either the
overall or the entry directionality of a given CharSequence is opposite to the context
directionality. Putting this before the CharSequence (including its directionality
declaration wrapping) prevents it from "sticking" to other opposite-directionality text
appearing before it inline with only neutral content in between. Otherwise returns the
empty string. While the entry directionality is determined by scanning the beginning of the
CharSequence, the overall directionality is given explicitly by a heuristic to estimate the
str's directionality.

@param str CharSequence before which the mark may need to appear.
@param heuristic The text direction heuristic that will be used to estimate the  str's
directionality.
Returns a Unicode bidi mark matching the context directionality ( LRM or RLM ) if either the overall or the entry directionality of a given CharSequence is opposite to the context directionality . Putting this before the CharSequence ( including its directionality declaration wrapping ) prevents it from " sticking " to other opposite - directionality text appearing before it inline with only neutral content in between . Otherwise returns the empty string . While the entry directionality is determined by scanning the beginning of the CharSequence the overall directionality is given explicitly by a heuristic to estimate the str ' s directionality . @param str CharSequence before which the mark may need to appear . @param heuristic The text direction heuristic that will be used to estimate the str ' s directionality .
private String markBefore(CharSequence str, TextDirectionHeuristicCompat heuristic) {
        final boolean isRtl = heuristic.isRtl(str, 0, str.length());
        if (!mIsRtlContext && (isRtl || getEntryDir(str) == DIR_RTL)) {
            return LRM_STRING;
        }
        if (mIsRtlContext && (!isRtl || getEntryDir(str) == DIR_LTR)) {
            return RLM_STRING;
        }
        return EMPTY_STRING;
    }
private String markBefore ( CharSequence str , TextDirectionHeuristicCompat heuristic ) { final boolean isRtl = heuristic . isRtl ( str , 0 , str . length ( ) ) ; if ( ! mIsRtlContext && ( isRtl || getEntryDir ( str ) == DIR_RTL ) ) { return LRM_STRING ; } if ( mIsRtlContext && ( ! isRtl || getEntryDir ( str ) == DIR_LTR ) ) { return RLM_STRING ; } return EMPTY_STRING ; }
Returns a Unicode bidi mark matching the context directionality (LRM or RLM) if either the
 overall or the entry directionality of a given CharSequence is opposite to the context
 directionality.
Returns a Unicode bidi mark matching the context directionality ( LRM or RLM ) if either the overall or the entry directionality of a given CharSequence is opposite to the context directionality .
// getEntryDir() is called only if needed (short-circuit).