# Substring function?

**URL:** <https://discourse.julialang.org/t/substring-function/76675>\
**Category:** New to Julia\
**Tags:** strings, unicode\
**Created:** [February 18, 2022, 7:41am UTC](https://discourse.julialang.org/t/substring-function/76675 "2022-02-18T07:41:49Z")\
**Posts on this page:** 1\
**Showing post:** 34

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [February 19, 2022, 3:18pm UTC](https://discourse.julialang.org/t/substring-function/76675/34 "2022-02-19T15:18:19Z")

</div>

> [@oheil](#):
>
> I don’t think expecting a working `substring` functionality isn’t that uncommon or even wrong like in “you are using substring, you are doing it probably wrong”.

Julia _has_ a working substring functionality, which works on string indices.

> [@oheil](#):
>
> I would prefer having just
> 
> ```julia-auto
> julia> SubString("äöü",2,3)
> "öü"
> 
> ```

The proposed character-indexing method does _not_ eliminate the complexities of Unicode. Consider:

```julia-auto
julia> substring(str, start, stop) = str[nextind(str, 0, start):nextind(str, 0, stop)]

julia> substring("äöü", 2,3) # NFC normalized string
"öü"

julia> substring("äöü", 2,3) # NFD normalized string
"̈o"

```

The supposed simplicity of “character indexing” is an illusion.

You pay a big price in performance to reduce apparent confusion on people’s first few days of using strings in Julia, but only postpone your Unicode bugs (because “characters” don’t mean what you think), and you get **zero benefits in the long run** (because indexing codepoint counts is not actually necessary for realistic string processing).

---

_[View the full topic](https://discourse.julialang.org/t/substring-function/76675)._
