# TextUtilsCompat

# TextUtilsCompat

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/text/TextUtilsCompat.java+class:androidx.core.text.TextUtilsCompat)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/text/TextUtilsCompat "View this page in Java")

<br />

```
class TextUtilsCompat
```

<br />

*** ** * ** ***

Backwards compatible version of[TextUtils](https://developer.android.com/reference/android/text/TextUtils.html).

## Summary

|                                      ### Public functions                                       |
|-------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)       | [getLayoutDirectionFromLocale](https://developer.android.com/reference/kotlin/androidx/core/text/TextUtilsCompat#getLayoutDirectionFromLocale(java.util.Locale))`(locale: `[Locale](https://developer.android.com/reference/java/util/Locale.html)`?)` Returns the layout direction for a given Locale |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [htmlEncode](https://developer.android.com/reference/kotlin/androidx/core/text/TextUtilsCompat#htmlEncode(java.lang.String))`(s: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Html-encode the string.                                                         |

## Public functions

### getLayoutDirectionFromLocale

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun getLayoutDirectionFromLocale(locale: Locale?): Int
```

Returns the layout direction for a given Locale  

|                                      Parameters                                      |
|--------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| `locale: `[Locale](https://developer.android.com/reference/java/util/Locale.html)`?` | the[Locale](https://developer.android.com/reference/java/util/Locale.html)for which we want the layout direction, maybe be`null`. |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the layout direction, either[LAYOUT_DIRECTION_LTR](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#LAYOUT_DIRECTION_LTR())or[LAYOUT_DIRECTION_RTL](https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#LAYOUT_DIRECTION_RTL()). |

### htmlEncode

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun htmlEncode(s: String): String
```

Html-encode the string.  

|                                       Parameters                                       |
|----------------------------------------------------------------------------------------|--------------------------|
| `s: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | the string to be encoded |

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|--------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | the encoded string |