# String indexing bug?

**URL:** <https://discourse.julialang.org/t/string-indexing-bug/79198>\
**Category:** General Usage\
**Tags:** bug, strings\
**Created:** [April 7, 2022, 10:34pm UTC](https://discourse.julialang.org/t/string-indexing-bug/79198 "2022-04-07T22:34:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)\
**Post date:** [April 7, 2022, 10:34pm UTC](https://discourse.julialang.org/t/string-indexing-bug/79198/1 "2022-04-07T22:34:42Z")

</div>

```nohighlight
str = "(θ,)"
str[3]

```

results in

```julia
ERROR: StringIndexError: invalid index [3], valid nearby indices [2]=>'θ', [4]=>','
Stacktrace:
 [1] string_index_err(s::String, i::Int64)
   @ Base ./strings/string.jl:12
 [2] getindex_continued(s::String, i::Int64, u::UInt32)
   @ Base ./strings/string.jl:235
 [3] getindex(s::String, i::Int64)
   @ Base ./strings/string.jl:228
 [4] top-level scope
   @ REPL[11]:1

```

I’m guessing maybe not a bug but unicode related. Still it feels unexpected to me. Should this be expected behaviour?

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [April 7, 2022, 10:47pm UTC](https://discourse.julialang.org/t/string-indexing-bug/79198/2 "2022-04-07T22:47:17Z")

</div>

See the [manual section on Unicode and UTF-8](https://docs.julialang.org/en/v1/manual/strings/#Unicode-and-UTF-8).

---

<div class="post-metadata">

**Author:** ![kodintent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kodintent/32/32225_2.png) [@kodintent](https://discourse.julialang.org/u/kodintent)\
**Post date:** [April 8, 2022, 12:48am UTC](https://discourse.julialang.org/t/string-indexing-bug/79198/3 "2022-04-08T00:48:24Z")

</div>

When i passed a filename containing θ to ffmpeg, ffmpeg rejected it because of that character.  
Some unicode chars are not fully supported yet and it seems a deep issue that hasnt been fixed after decades.

---

<div class="post-metadata">

**Author:** ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)\
**Post date:** [April 8, 2022, 1:54am UTC](https://discourse.julialang.org/t/string-indexing-bug/79198/4 "2022-04-08T01:54:30Z")

</div>

Thank you for pointing me to the relevant part of the manual.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [April 8, 2022, 5:22am UTC](https://discourse.julialang.org/t/string-indexing-bug/79198/5 "2022-04-08T05:22:49Z")

</div>

There have been several threads on this subject, one recently prompted this PR: [https://github.com/JuliaLang/julia/pull/44266](https://github.com/JuliaLang/julia/pull/44266)
