Regex and unicode returning wrong indexes

how could I get the right result?

For exactly this example

iex(1)> [before, _after] = :binary.split("áéíóúx", "x")
["áéíóú", ""]
iex(2)> String.length(before)
5

seems to work.