compat/src/main/java/androidx/core/text/BidiFormatter.java
private String markAfter(CharSequence str, TextDirectionHeuristicCompat heuristic) {
        final boolean isRtl = heuristic.isRtl(str, 0, str.length());
        // getExitDir() is called only if needed (short-circuit).
        if (!mIsRtlContext && (isRtl || getExitDir(str) == DIR_RTL)) {
            return LRM_STRING;
        }
        if (mIsRtlContext && (!isRtl || getExitDir(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 exit directionality of a given CharSequence is opposite to the context
     * directionality. Putting this after the CharSequence (including its directionality
     * declaration wrapping) prevents it from "sticking" to other opposite-directionality text or a
     * number appearing after it inline with only neutral content in between. Otherwise returns
     * the empty string. While the exit directionality is determined by scanning the end of the
     * CharSequence, the overall directionality is given explicitly by a heuristic to estimate the
     * {@code str}'s directionality.
     *
     * @param str CharSequence after 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 .
     */
Returns a Unicode bidi mark matching the context directionality (LRM or RLM) if either the
overall or the exit directionality of a given CharSequence is opposite to the context
directionality. Putting this after the CharSequence (including its directionality
declaration wrapping) prevents it from "sticking" to other opposite-directionality text or a
number appearing after it inline with only neutral content in between. Otherwise returns
the empty string. While the exit directionality is determined by scanning the end of the
CharSequence, the overall directionality is given explicitly by a heuristic to estimate the
str's directionality.

@param str CharSequence after 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 exit directionality of a given CharSequence is opposite to the context directionality . Putting this after the CharSequence ( including its directionality declaration wrapping ) prevents it from " sticking " to other opposite - directionality text or a number appearing after it inline with only neutral content in between . Otherwise returns the empty string . While the exit directionality is determined by scanning the end of the CharSequence the overall directionality is given explicitly by a heuristic to estimate the str ' s directionality . @param str CharSequence after 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 markAfter(CharSequence str, TextDirectionHeuristicCompat heuristic) {
        final boolean isRtl = heuristic.isRtl(str, 0, str.length());
        if (!mIsRtlContext && (isRtl || getExitDir(str) == DIR_RTL)) {
            return LRM_STRING;
        }
        if (mIsRtlContext && (!isRtl || getExitDir(str) == DIR_LTR)) {
            return RLM_STRING;
        }
        return EMPTY_STRING;
    }
private String markAfter ( CharSequence str , TextDirectionHeuristicCompat heuristic ) { final boolean isRtl = heuristic . isRtl ( str , 0 , str . length ( ) ) ; if ( ! mIsRtlContext && ( isRtl || getExitDir ( str ) == DIR_RTL ) ) { return LRM_STRING ; } if ( mIsRtlContext && ( ! isRtl || getExitDir ( 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 exit 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 exit directionality of a given CharSequence is opposite to the context directionality .
// getExitDir() is called only if needed (short-circuit).