> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/s/string_length.md).

# String length

```ruby
var str = "J\x{332}o\x{332}s\x{332}e\x{301}\x{332}"
```

### Byte Length

UTF-8 byte length (default):

```ruby
say str.bytes.len       #=> 14
```

UTF-16 byte length:

```ruby
say str.encode('UTF-16').bytes.len      #=> 20
```

### Character Length

```ruby
say str.chars.len    #=> 9
```

### Grapheme Length

```ruby
say str.graphs.len   #=> 4
```
