# CharsetDetector

Artifact: [androidx.media3:media3-extractor](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/extractor/text/CharsetDetector.java+class:androidx.media3.extractor.text.CharsetDetector)

*** ** * ** ***


```
@UnstableApi
interface CharsetDetector
```

<br />

*** ** * ** ***

Detects the character encoding of subtitle byte data.

## Summary

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/java/nio/charset/Charset.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/text/CharsetDetector#detect(byte[],int,int)(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Detects the character encoding of the requested range of `data`. |

## Public functions

### detect

```
fun detect(data: ByteArray<Byte>!, offset: Int, length: Int): Charset?
```

Detects the character encoding of the requested range of `data`.

The requested range is not guaranteed to contain a complete subtitle file.

| Parameters |
|---|---|
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The subtitle byte data. |
| `offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The start offset in `data`. |
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bytes to inspect. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/nio/charset/Charset.html?` | The detected character encoding, or `null` if it could not be determined. |