# tensorflow::ops::StringLength Class Reference

# tensorflow::ops::StringLength

`#include <string_ops.h>`

String lengths of `input`.

## Summary

Computes the length of each string given in the input tensor.

strings = tf.constant(\['Hello','TensorFlow', ''\]) tf.strings.length(strings).numpy() # default counts bytes array(\[ 5, 10, 4\], dtype=int32) tf.strings.length(strings, unit="UTF8_CHAR").numpy() array(\[ 5, 10, 1\], dtype=int32)

Arguments:

- scope: A [Scope](https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object
- input: The strings for which to compute the length for each element.

<br />

Optional attributes (see `https://www.tensorflow.org/versions/r2.3/api_docs/cc/struct/tensorflow/ops/string-length/attrs#structtensorflow_1_1ops_1_1_string_length_1_1_attrs`):

- unit: The unit that is counted to compute string length. One of: `"BYTE"` (for the number of bytes in each string) or `"UTF8_CHAR"` (for the number of UTF-8 encoded Unicode code points in each string). Results are undefined if `unit=UTF8_CHAR` and the `input` strings do not contain structurally valid UTF-8.

<br />

Returns:

- `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output`: Integer tensor that has the same shape as `input`. The output contains the element-wise string lengths of `input`.

<br />

| ### Constructors and Destructors ||
|---|---|
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/string-length#classtensorflow_1_1ops_1_1_string_length_1a7bf80700ba30572d7c7ca2b6f850eaca(const ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input)` ||
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/string-length#classtensorflow_1_1ops_1_1_string_length_1a1a20dc90501bbdb2e17e0b5964a8eff1(const ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input, const https://www.tensorflow.org/versions/r2.3/api_docs/cc/struct/tensorflow/ops/string-length/attrs#structtensorflow_1_1ops_1_1_string_length_1_1_attrs & attrs)` ||

| ### Public attributes ||
|---|---|
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/string-length#classtensorflow_1_1ops_1_1_string_length_1a17a8867ada18bd6238863a038adb4072` | `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation` |
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/string-length#classtensorflow_1_1ops_1_1_string_length_1a3c952cda013f2825ee48c9cba19fa974` | `::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output` |

| ### Public functions ||
|---|---|
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/string-length#classtensorflow_1_1ops_1_1_string_length_1a8958d29822235046d6f74f45f90f9ee2() const ` | `::tensorflow::Node *` |
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/string-length#classtensorflow_1_1ops_1_1_string_length_1ad02392f74af341966e713678ada76cf3() const ` | ` `` ` |
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/string-length#classtensorflow_1_1ops_1_1_string_length_1a75c524b5ff956f3f681cdebb8135460f() const ` | ` `` ` |

| ### Public static functions ||
|---|---|
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/string-length#classtensorflow_1_1ops_1_1_string_length_1af57b9def6e863b9003b3fc809a13d835(StringPiece x)` | `https://www.tensorflow.org/versions/r2.3/api_docs/cc/struct/tensorflow/ops/string-length/attrs#structtensorflow_1_1ops_1_1_string_length_1_1_attrs` |

| ### Structs ||
|---|---|
| [tensorflow::ops::StringLength::Attrs](https://www.tensorflow.org/versions/r2.3/api_docs/cc/struct/tensorflow/ops/string-length/attrs) | Optional attribute setters for [StringLength](https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/string-length#classtensorflow_1_1ops_1_1_string_length). |

## Public attributes

### operation

```
Operation operation
```

### output

```
::tensorflow::Output output
```

## Public functions

### StringLength

```
 StringLength(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input
)
```

### StringLength

```
 StringLength(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  const StringLength::Attrs & attrs
)
```

### node

```
::tensorflow::Node * node() const 
```

### operator::tensorflow::Input

```
 operator::tensorflow::Input() const 
```

### operator::tensorflow::Output

```
 operator::tensorflow::Output() const 
```

## Public static functions

### Unit

```
Attrs Unit(
  StringPiece x
)
```